【发布时间】:2017-02-02 00:22:07
【问题描述】:
我正在尝试使用 UIBezierPath 制作一个进度弧,它将绕一个完整的圆圈并在它到达正确的进度后完成动画。所以本质上它需要做一个完整的 360 度,然后走多远来满足它的进步。截至目前,我只能将其设置为动画以使其到达结束角度,如下所示:
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 2.0; // "animate over 10 seconds or so.."
drawAnimation.repeatCount = 1.0; // Animate only once..
// Animate from no part of the stroke being drawn to the entire stroke being drawn
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];
// Experiment with timing to get the appearence to look the way you want
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
// Add the animation to the circle
static dispatch_once_t once;
dispatch_once(&once, ^ {
[progressArc addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
});
我怎样才能让我的圆弧以这样的方式进行动画处理,让它一直环绕并停在正确的结束角度?
【问题讨论】:
-
“所以基本上它需要做一个完整的 360 度,然后走多远才能满足它的进步”但是你如何能够看到它做这个?例如,如果一个红色圆圈将自己拉成一个完整的圆圈,然后继续前进,那么您只是在已经有红色的地方添加了更多的红色。除了一个完整的圆圈之外,将无法看到任何东西。
标签: ios objective-c