17 iphone core-animation objective-c cgpath
我想基于CGPath为CALayer的位置设置动画,但我想向后播放它.
有没有办法让路径向后动画,或者反转CGPath?
这可能不是最好的解决方案,但它对我有用。我告诉动画自动反转,然后中途启动它。但为了防止它再次动画回来,我需要提前终止它。
- (void) animate {
CAKeyframeAnimation * pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.path = path;
pathAnimation.duration = 15.0;
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.timeOffset = pathAnimation.duration;
pathAnimation.autoreverses = YES;
NSString * key = @"pathAnimation";
[animatedView.layer addAnimation:pathAnimation forKey:key];
[NSTimer scheduledTimerWithTimeInterval:pathAnimation.duration target:self selector:@selector(endAnimation:) userInfo:key repeats:NO];
}
- (void) endAnimation:(NSTimer *)timer {
[animatedView.layer removeAnimationForKey:timer.userInfo];
}
Run Code Online (Sandbox Code Playgroud)
如果存在更好的方法,我想知道。
| 归档时间: |
|
| 查看次数: |
3261 次 |
| 最近记录: |