//bgView 是一个UIView,我将它作为底图
//以bgView 为基准选定位置
CGPoint pathCenter = CGPointMake(bgView.frame.size.width/2, bgView.frame.size.height/2 - 50);
//画出一个圆(起始为0,画360°,半径为40)
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:pathCenter radius:40 startAngle:0 endAngle:M_PI *2 clockwise:YES];
path.lineCapStyle = kCGLineCapRound; // 线条拐角
path.lineJoinStyle = kCGLineCapRound; // 线条终点处理
//画勾(起点,最低点,最高点)并将画的线添加上去
CGFloat x = bgView.frame.size.width/2.5 + 5;
CGFloat y = bgView.frame.size.height/2 - 45;
[path moveToPoint:CGPointMake(x, y)];
[path addLineToPoint:CGPointMake(x + 10, y + 30)];
[path addLineToPoint:CGPointMake(x + 50, y - 30)];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
//图层中线条的颜色
layer.strokeColor = [[UIColor redColor] CGColor];
layer.path = path.CGPath;
//图层未画图部分填充色,默认是黑色
layer.fillColor = [UIColor clearColor].CGColor;
//图层中线条宽度
layer.lineWidth = 5;
//添加动画,图层上的线条呈现画的效果
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:NSStringFromSelector(@selector(strokeStart))];
animation.fromValue = @0;
animation.toValue = @1;
animation.duration = 0.5;
[layer addAnimation:animation forKey:NSStringFromSelector(@selector(strokeStart))];
[bgView.layer addSublayer:layer];
转载于:https://my.oschina.net/u/2507274/blog/598593