您的位置:首页 > 产品设计 > UI/UE

IOS利用UIBezierPath画动画圆

2015-01-28 16:42 183 查看
- (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];
arcLayer = [CAShapeLayer layer];
arcLayer.path = path.CGPath;
//arcLayer.strokeColor可设置画笔颜色
arcLayer.lineWidth = 10;
arcLayer.frame = self.bounds;
arcLayer.fillColor = [UIColor whiteColor].CGColor;
[self.layer addSublayer:arcLayer];

//动画显示圆则调用  [self drawLineAnimation:arcLayer];
}

- (void)drawLineAnimation:(CALayer*)layer {
CABasicAnimation *bas = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
bas.duration = 1;
bas.delegate = self;
bas.fromValue = [NSNumber numberWithInteger:0];
bas.toValue = [NSNumber numberWithInteger:1];
[layer addAnimation:bas forKey:@"key"];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: