#import <QuartzCore/QuartzCore.h> - (void) spinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat; { CABasicAnimation *animation; animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * rotations * duration ]; animation.duration = duration; animation.cumulative = YES; animation.repeatCount = repeat; [view.layer addAnimation:animation forKey:@"rotationAnimation"]; }
|