Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BOOL animating;
- BOOL animationPending;
- BOOL animationComplete;
- - (void)rotateWithOptions:(UIViewAnimationOptions)options {
- NSTimeInterval fullRotationInterval = 4.0;
- [UIView animateWithDuration:fullRotationInterval/4.0 delay:0 options:options animations:^{
- self.musicIconImageView.transform = CGAffineTransformRotate(self.musicIconImageView.transform, M_PI_2);
- } completion:^(BOOL finished) {
- if (animating) {
- [self rotateWithOptions:UIViewAnimationOptionCurveLinear];
- } else if (animationPending) {
- animationPending = NO;
- animating = YES;
- [self rotateWithOptions:UIViewAnimationOptionBeginFromCurrentState];
- } else if ((options & UIViewAnimationOptionCurveEaseOut) == 0) {
- // Last spin
- [self rotateWithOptions:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut];
- } else {
- animationComplete = NO;
- }
- }];
- }
- - (void)startRotation {
- animationComplete = NO;
- if (!animating) {
- if (animationComplete) {
- animationPending = YES;
- } else {
- animating = YES;
- [self rotateWithOptions:UIViewAnimationOptionCurveEaseIn];
- }
- }
- }
- - (void)stopRotation {
- animating = NO;
- animationComplete = YES;
- }
Add Comment
Please, Sign In to add comment