您的位置:首页 > 其它

Quartz2D - 基本图形绘制(形状)

2016-03-06 16:00 429 查看
1.空心圆圈



// 创建
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 200) cornerRadius:100];

// 设置属性
path.lineWidth = 5;
path.lineCapStyle = kCGLineCapRound;
path.lineJoinStyle = kCGLineJoinRound;
[[UIColor redColor] set];

// 绘制
[path stroke];


2.实心圆


// 创建
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 200) cornerRadius:100];

// 设置属性
path.lineWidth = 5;
path.lineCapStyle = kCGLineCapRound;
path.lineJoinStyle = kCGLineJoinRound;
[[UIColor redColor] set];

// 填充(必须是一个完整的封闭路径)
[path fill];


3.圆弧



/*
center:圆心
startAngle: 弧度
clockwise:YES顺时针/NO逆时针
*/
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:100 startAngle:0 endAngle:-M_PI_2 clockwise:NO];

path.lineWidth = 5;
[[UIColor orangeColor] set];

[path stroke];


4.扇形



// 扇形
CGPoint center = CGPointMake(150, 150);
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:100 startAngle:0 endAngle:-M_PI_2 clockwise:NO];

// 添加一根线到圆心
[path addLineToPoint:center];
// 关闭路径(从路径的终点到起点)
[path closePath];

path.lineWidth = 5;
[[UIColor redColor] set];

[path fill];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: