Question

Avec iPhone CALayer, je souhaite une animation de rotation pour mon calque d'esprit, mais je souhaite également un rappel pour la fin de l'animation, cela vous tente-t-il?

Je pense que je devrais peut-être utiliser CABasicAnimation, mais je ne sais pas comment effectuer une rotation avec CABasicAnimation, vous avez une idée?

Merci

Était-ce utile?

La solution

Si vous définissez un délégué pour CAAnimation, vous pouvez ajouter la méthode de rappel:

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag

Cela est appelé lorsque l'animation est terminée. Recherchez des exemples d'animation en rotation via une matrice de transformation CGAffineTransform, selon ce lien:

http://iphonedevelopment.blogspot.com/2008/10/demystifying- cgaffinetransform.html

Autres conseils

En passant, vous pouvez également faire le même type de rappel pour une animation UIView en encapsulant votre appel pour faire pivoter UIView dans le bloc de code suivant

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(rotationAnimationHasFinished:finished:context:)];
// Rotate the view here
[UIView commitAnimations];

puis en définissant une méthode de délégation

- (void)rotationAnimationHasFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context;
{
// Handle the completion of the animation
}

au sein de votre délégué, qui fera tout ce dont vous aurez besoin une fois l'animation terminée.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top