【发布时间】:2014-12-05 19:09:38
【问题描述】:
我正在尝试创建一个圆形条,当您进行延时摄影时,您可以在 iOS 原生相机的录制按钮周围找到它。
沿着动画创建一个圆圈,一旦完成,就会“自然”地再次删除。
我尝试了下一个代码:
CAShapeLayer *circle = [CAShapeLayer layer];
circle.path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.lapseBtnOutlet.center.x, self.lapseBtnOutlet.center.y) radius:28 startAngle:2*M_PI*0-M_PI_2 endAngle:2*M_PI*1-M_PI_2 clockwise:YES].CGPath;
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor whiteColor].CGColor;
circle.lineWidth = 2.0;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
animation.duration = self.lapseInterval;
animation.removedOnCompletion = NO;
animation.fromValue = @(0);
animation.toValue = @(1);
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[circle addAnimation:animation forKey:@"drawCircleAnimation"];
但我现在的问题是我不知道如何从头到尾“删除”这条线。
我尝试使用 autoreverse 属性,但它从头到尾删除了圆,而不是从头到尾。有任何想法吗?
【问题讨论】:
标签: ios uibezierpath cabasicanimation