Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 可以在动画中向后播放路径吗?_Iphone_Objective C_Core Animation_Cgpath - Fatal编程技术网

Iphone 可以在动画中向后播放路径吗?

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设置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];
}
如果有更好的办法,我想知道

animation.speed = -1;

是的。那肯定更好。我希望我早一点想到。你从哪里学来的?我在苹果文档中找不到这个功能。