-
第一种是创建一个UIView子类, 用UIBezierPath画圆。
创建和使用path对象步骤:
1、 重写View的drawRect
方法
2、 创建UIBezierPath
的对象
3、 使用方法moveToPoint:
设置初始点
4、 根据具体要求使用UIBezierPath
类方法绘图(比如要画线、矩形、圆、弧?等)
5、 设置UIBezierPath
对象相关属性 (比如lineWidth
、lineJoinStyle
、aPath.lineCapStyle
、color
)
6、 使用stroke 或者 fill方法结束绘图
- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(10, 10)];
[path addLineToPoint:CGPointMake(200, 80)];
path.lineWidth = 5.0;
path.lineCapStyle = kCGLineCapRound; //线条拐角
path.lineJoinStyle = kCGLineJoinRound; //终点处理
[path stroke];
}