Iphone 可以在动画中向后播放路径吗?
我想根据CGPath设置CALayer位置的动画,但我想向后播放Iphone 可以在动画中向后播放路径吗?,iphone,objective-c,core-animation,cgpath,Iphone,Objective C,Core Animation,Cgpath,我想根据CGPath设置CALayer位置的动画,但我想向后播放 有没有办法向后设置路径动画,或者反转CGPath?这可能不是最好的解决方案,但对我来说很有效。我让动画自动翻转,然后在一半的时候开始。但是为了防止它再次动画化,我需要提前终止它 - (void) animate { CAKeyframeAnimation * pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAni
有没有办法向后设置路径动画,或者反转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];
}
如果有更好的办法,我想知道
animation.speed = -1;
是的。那肯定更好。我希望我早一点想到。你从哪里学来的?我在苹果文档中找不到这个功能。