Desidero animare la posizione di un CALayer basato su un CGPath, ma voglio riprodurlo all'indietro.È possibile riprodurre un percorso all'indietro in una CAKeyFrameAnimation?
C'è un modo per animare un percorso all'indietro o invertire un CGPath?
Desidero animare la posizione di un CALayer basato su un CGPath, ma voglio riprodurlo all'indietro.È possibile riprodurre un percorso all'indietro in una CAKeyFrameAnimation?
C'è un modo per animare un percorso all'indietro o invertire un CGPath?
Questa potrebbe non essere la soluzione migliore, ma ha funzionato per me. Ho detto all'animazione di eseguire l'autoreverse, quindi l'ho avviato a metà. Ma per impedirgli di tornare ad animare di nuovo, dovevo terminarlo prima.
- (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];
}
Se esiste un modo migliore, mi piacerebbe sapere.
animation.speed = -1;
?
Sì. Questo è decisamente meglio. Vorrei averlo pensato prima. –
Sicuramente grande grazie! – BoilingLime
Dove l'hai imparato? Non riesco a trovare in apple doc questa funzione. – surfrider