Quiero animar la posición de un CALayer basado en un CGPath, pero quiero reproducirlo al revés.¿Es posible reproducir un camino hacia atrás en una CAKeyFrameAnimation?
¿Hay alguna manera de animar un camino hacia atrás o invertir un CGPath?
Quiero animar la posición de un CALayer basado en un CGPath, pero quiero reproducirlo al revés.¿Es posible reproducir un camino hacia atrás en una CAKeyFrameAnimation?
¿Hay alguna manera de animar un camino hacia atrás o invertir un CGPath?
Puede que esta no sea la mejor solución, pero funcionó para mí. Le dije a la animación que se revirtiera automáticamente, y luego comencé a medio camino. Pero para evitar que volviera a animar, necesitaba terminarla antes.
- (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];
}
Si existe una manera mejor, me gustaría saber.
animation.speed = -1;
?
Sí. Eso es definitivamente mejor. Ojalá hubiera pensado en eso antes. –
¡Definitivamente grandes gracias! – BoilingLime
¿Dónde lo aprendiste? No puedo encontrar en Apple Docs esta característica. – surfrider