UIView rotate Infinite

1
2
3
4
5
6
7
8
9
10
11
12
13
#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"];
}