UIBezierPath的使用方式:
一,直接新增軌跡,然後stroke或者fill
UIColor *blue =[UIColor blueColor];
[blue set];
UIBezierPath *bezier =[UIBezierPath bezierPath];
bezier.lineWidth=2;
bezier.lineCapStyle=kCGLineCapRound;
bezier.lineJoinStyle=kCGLineJoinRound;
[bezier moveToPoint:CGPointMake(50, 5)];
[bezier addLineToPoint:CGPointMake(90, 25)];
[bezier addLineToPoint:CGPointMake(75, 50)];
[bezier addLineToPoint:CGPointMake(25, 50)];
[bezier closePath];
[bezier fill];
二,建立UIBezierPath物件,並將去path新增到layer上面
UIBezierPath *bezier2 =[UIBezierPath bezierPathWithArcCenter:CGPointMake(50, 50) radius:20 startAngle:0 endAngle:M_PI clockwise:YES];
CAShapeLayer *layer =[CAShapeLayer layer];
layer.path=bezier2.CGPath;
layer.strokeColor=[UIColor redColor].CGColor;
layer.fillColor=[UIColor blueColor].CGColor;
layer.borderWidth=1;
[self.layer addSublayer:layer];