实例:
- (void)drawRoundView:(CGPoint)centerPoint withStartAngle:(CGFloat)startAngle withEndAngle:(CGFloat)endAngle withRadius:(CGFloat)radius {
UIBezierPath *path = [UIBezierPath bezierPath];
[path addArcWithCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES];
self.arcLayer = [CAShapeLayer layer];
self.arcLayer.path = path.CGPath;
self.arcLayer.strokeColor = [UIColor blueColor].CGColor;
//arcLayer.strokeColor可设置画笔颜色
self.arcLayer.lineWidth = 10;
self.arcLayer.frame = self.view.bounds;
self.arcLayer.fillColor = [UIColor clearColor].CGColor;
[self.view.layer addSublayer:self.arcLayer];
// 动画显示圆则调用
[self drawLineAnimation:self.arcLayer];
}
- (void)drawLineAnimation:(CALayer*)layer {
CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
bas.duration = 1;
bas.fromValue = [NSNumber numberWithInteger:0];
bas.toValue = [NSNumber numberWithInteger:1];
[layer addAnimation:bas forKey:@"key"];
}
网友评论