Guest User

Untitled

a guest
Oct 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. BOOL animating;
  2. BOOL animationPending;
  3. BOOL animationComplete;
  4.  
  5. - (void)rotateWithOptions:(UIViewAnimationOptions)options {
  6. NSTimeInterval fullRotationInterval = 4.0;
  7. [UIView animateWithDuration:fullRotationInterval/4.0 delay:0 options:options animations:^{
  8. self.musicIconImageView.transform = CGAffineTransformRotate(self.musicIconImageView.transform, M_PI_2);
  9. } completion:^(BOOL finished) {
  10. if (animating) {
  11. [self rotateWithOptions:UIViewAnimationOptionCurveLinear];
  12. } else if (animationPending) {
  13. animationPending = NO;
  14. animating = YES;
  15. [self rotateWithOptions:UIViewAnimationOptionBeginFromCurrentState];
  16. } else if ((options & UIViewAnimationOptionCurveEaseOut) == 0) {
  17. // Last spin
  18. [self rotateWithOptions:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut];
  19. } else {
  20. animationComplete = NO;
  21. }
  22. }];
  23. }
  24.  
  25. - (void)startRotation {
  26. animationComplete = NO;
  27. if (!animating) {
  28. if (animationComplete) {
  29. animationPending = YES;
  30. } else {
  31. animating = YES;
  32. [self rotateWithOptions:UIViewAnimationOptionCurveEaseIn];
  33. }
  34. }
  35. }
  36.  
  37. - (void)stopRotation {
  38. animating = NO;
  39. animationComplete = YES;
  40. }
Add Comment
Please, Sign In to add comment