Ответ 1
animation.speed = -1;
?
Я хочу оживить положение CALayer на основе CGPath, но я хочу воспроизвести его назад.
Есть ли способ анимировать путь назад или изменить CGPath?
animation.speed = -1;
?
Это может быть не лучшее решение, но это сработало для меня. Я сказал анимации autoreverse, а затем начал ее на полпути. Но чтобы предотвратить ее оживление назад, мне нужно было закончить его раньше.
- (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];
}
Если существуют лучшие способы, я хотел бы знать.