CGPathに基づいてCALayerの位置をアニメートしたいのですが、逆方向に再生したいと思います。
パスを逆方向にアニメーション化する方法、またはCGPathを逆方向にする方法はありますか?
CGPathに基づいてCALayerの位置をアニメートしたいのですが、逆方向に再生したいと思います。
パスを逆方向にアニメーション化する方法、またはCGPathを逆方向にする方法はありますか?
animation.speed = -1;
?
これは最善の解決策ではないかもしれませんが、私にとってはうまくいきました。私はアニメーションに自動反転を指示し、途中で開始しました。
- (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];
}
もっと良い方法があれば、知りたいです。