Does animation end callback for CALayer?

Using iPhone CALayer, I want a rotation animation for my spirit layer, but I also need a callback for the end of the animation, hot for this?

I think maybe I should use CABasicAnimation, but I don’t know how to do rotation using CABasicAnimation, any idea?

thanks

+5
source share
2 answers

If you set a delegate for CAAnimation, you can add a callback method:

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

This is called when the animation is complete. See examples of rotating animations using the CGAffineTransform transformation matrix, according to this link:

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

+6

, UIView, , UIView

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

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

, , , .

+3

All Articles