Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  AnimatedLogoView.m
  3. //  GetMeet
  4. //
  5. //  Created by Igor Starzhinskiy on 09.09.16.
  6. //  Copyright © 2016 alex. All rights reserved.
  7. //
  8.  
  9. #import "AnimatedLogoView.h"
  10.  
  11. @interface AnimatedLogoView ()
  12.  
  13. enum AnimationLogoType {
  14.     ANone,
  15.     AStart,
  16.     AHalfStart,
  17.     ABack,
  18.     AActivity
  19. };
  20.  
  21. @property (strong, nonatomic) UIImageView *logoCompleteView;
  22.  
  23. @property (strong, nonatomic) UIImageView *logoLeftUpView;
  24. @property (strong, nonatomic) UIImageView *logoRightUpView;
  25. @property (strong, nonatomic) UIImageView *logoRigthDownView;
  26. @property (strong, nonatomic) UIImageView *logoLeftDownView;
  27.  
  28. @property (strong, nonatomic) UIView *circleView;
  29.  
  30. @property (strong, nonatomic) UIImageView *logoMView;
  31. @property (strong, nonatomic) UIImageView *logoGetView;
  32. @property (strong, nonatomic) UIImageView *logoEetView;
  33.  
  34. //@property (assign, nonatomic) BOOL isAnimating;
  35. //@property (assign, nonatomic) BOOL isBackAnimation;
  36. //@property (assign, nonatomic) BOOL isHalfStartAnimation;
  37.  
  38. @property (assign, nonatomic) enum AnimationLogoType animationType;
  39.  
  40. @property (assign, nonatomic) BOOL stopAction;
  41. @property (assign, nonatomic) BOOL animateBackWhenStopped;
  42. @property (assign, nonatomic) BOOL animateStartWhenStopped;
  43.  
  44.  
  45. @end
  46.  
  47.  
  48. @implementation AnimatedLogoView
  49.  
  50. #pragma mark - Inits
  51.  
  52. - (void)setup {
  53.    
  54.     self.backgroundColor = [UIColor clearColor];
  55.     CGPoint center = self.center;
  56.    
  57.     //self.isAnimating = NO;
  58.     _animationType = ANone;
  59.     self.logoCompleteView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"GetMeet_logo_auth"]];
  60.     self.bounds = self.logoCompleteView.bounds;
  61.     self.center = center;
  62.    
  63.     self.logoLeftUpView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_left_up"]];
  64.     self.logoRightUpView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_right_up"]];
  65.     self.logoRigthDownView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_right_down"]];
  66.     self.logoLeftDownView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_left_down"]];
  67.    
  68.     self.circleView = [[UIView alloc] initWithFrame:self.logoLeftUpView.frame];
  69.     self.circleView.center = CGPointMake(self.bounds.size.width / 2.f, self.bounds.size.height / 2.f);
  70.     self.circleView.backgroundColor = [UIColor clearColor];
  71.     self.circleView.hidden = NO;
  72.    
  73.     self.logoMView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_m"]];
  74.     self.logoGetView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_get"]];
  75.     self.logoEetView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo_eet"]];
  76.    
  77.     self.logoCompleteView.hidden = YES;
  78.    
  79.     self.logoLeftUpView.hidden = YES;
  80.     self.logoRightUpView.hidden = YES;
  81.     self.logoRigthDownView.hidden = YES;
  82.     self.logoLeftDownView.hidden = YES;
  83.    
  84.     self.logoMView.hidden = YES;
  85.     self.logoGetView.hidden = YES;
  86.     self.logoEetView.hidden = YES;
  87.    
  88.     [self addSubview:self.logoCompleteView];
  89.    
  90.     [self.circleView addSubview:self.logoLeftUpView];
  91.     [self.circleView addSubview:self.logoRightUpView];
  92.     [self.circleView addSubview:self.logoRigthDownView];
  93.     [self.circleView addSubview:self.logoLeftDownView];
  94.    
  95.     [self addSubview:self.circleView];
  96.    
  97.     [self addSubview:self.logoMView];
  98.     [self addSubview:self.logoGetView];
  99.     [self addSubview:self.logoEetView];
  100. }
  101.  
  102. - (instancetype)initWithCoder:(NSCoder *)coder
  103. {
  104.     self = [super initWithCoder:coder];
  105.     if (self) {
  106.         [self setup];
  107.     }
  108.     return self;
  109. }
  110.  
  111. - (instancetype)initWithFrame:(CGRect)frame {
  112.     self = [super initWithFrame:frame];
  113.     if (self) {
  114.         [self setup];
  115.     }
  116.     return self;
  117. }
  118.  
  119. /*
  120. // Only override drawRect: if you perform custom drawing.
  121. // An empty implementation adversely affects performance during animation.
  122. - (void)drawRect:(CGRect)rect {
  123.     // Drawing code
  124. }
  125. */
  126.  
  127.  
  128. #pragma mark - Public methods
  129.  
  130. - (void)startAnimation {
  131.    
  132.     if (_animationType != ANone) {
  133.         if (_animationType == ABack) {
  134.             self.animateStartWhenStopped = YES;
  135.         }
  136.         return;
  137.     }
  138.    
  139.     //self.isAnimating = YES;
  140.     //self.isBackAnimation = NO;
  141.     _animationType = AStart;
  142.    
  143.     self.logoCompleteView.hidden = YES;
  144.    
  145.     self.logoLeftUpView.hidden = YES;
  146.     self.logoRightUpView.hidden = YES;
  147.     self.logoRigthDownView.hidden = YES;
  148.     self.logoLeftDownView.hidden = YES;
  149.    
  150.     self.logoMView.hidden = YES;
  151.     self.logoGetView.hidden = YES;
  152.     self.logoEetView.hidden = YES;
  153.    
  154.     [self performSelector:@selector(animateStage1) withObject:nil afterDelay:0.1f];
  155.     [self performSelector:@selector(animateStage2) withObject:nil afterDelay:0.3f];
  156.     [self performSelector:@selector(animateStage5) withObject:nil afterDelay:0.4f]; //start rotating left
  157.     [self performSelector:@selector(animateStage3) withObject:nil afterDelay:0.5f];
  158.     [self performSelector:@selector(animateStage4) withObject:nil afterDelay:0.7f];
  159.    
  160. }
  161.  
  162. - (void)backAnimation {
  163.    
  164.     if (_animationType != ANone) {
  165.         if (_animationType == AStart || _animationType == AHalfStart) {
  166.             self.animateBackWhenStopped = YES;
  167.         }
  168.         return;
  169.     }
  170.     //self.isAnimating = YES;
  171.     //self.isBackAnimation = YES;
  172.     _animationType = ABack;
  173.    
  174.     self.logoCompleteView.hidden = YES;
  175.    
  176.     self.logoLeftUpView.hidden = NO;
  177.     self.logoRightUpView.hidden = NO;
  178.     self.logoRigthDownView.hidden = NO;
  179.     self.logoLeftDownView.hidden = NO;
  180.    
  181.     self.logoMView.hidden = NO;
  182.     self.logoGetView.hidden = NO;
  183.     self.logoEetView.hidden = NO;
  184.    
  185.     [self performSelector:@selector(backAnimateGet) withObject:nil afterDelay:0.05f];
  186.     [self performSelector:@selector(backAnimateRotate) withObject:nil afterDelay:0.2f];
  187.     [self performSelector:@selector(backAnimateEet) withObject:nil afterDelay:0.15f];
  188. }
  189.  
  190. - (void)halfStartAnimation {
  191.    
  192.     if (_animationType == AStart || _animationType == AHalfStart || _animationType == AActivity) {
  193.         self.animateBackWhenStopped = NO;
  194.         return;
  195.     }
  196.    
  197.     _animationType = AHalfStart;
  198.    
  199.     BOOL animateBackBefore = NO;
  200.    
  201.     if (!self.logoCompleteView.hidden || !self.logoGetView.hidden || !self.logoEetView.hidden) {
  202.         self.logoCompleteView.hidden = YES;
  203.         animateBackBefore = YES;
  204.         self.logoGetView.hidden = NO;
  205.         self.logoEetView.hidden = NO;
  206.     }
  207.    
  208.     self.logoLeftUpView.hidden = NO;
  209.     self.logoRightUpView.hidden = NO;
  210.     self.logoRigthDownView.hidden = NO;
  211.     self.logoLeftDownView.hidden = NO;
  212.    
  213.     self.logoMView.hidden = NO;
  214.    
  215.     if (animateBackBefore) {
  216.        
  217.         [self performSelector:@selector(backAnimateGet) withObject:nil afterDelay:0.05f];
  218.         [self performSelector:@selector(backAnimateEet) withObject:nil afterDelay:0.15f];
  219.         [self performSelector:@selector(backAnimateRotate) withObject:nil afterDelay:0.2f];
  220.        
  221.     } else {
  222.         [self performSelector:@selector(backAnimateRotate) withObject:nil afterDelay:0.1f];
  223.     }
  224.    
  225. }
  226.  
  227. - (void)stopAnimation {
  228.     self.stopAction = YES;
  229. }
  230.  
  231. - (void)startActivityIndication {
  232.     _animationType = AActivity;
  233.    
  234.     self.logoCompleteView.hidden = YES;
  235.    
  236.     self.logoLeftUpView.hidden = NO;
  237.     self.logoRightUpView.hidden = NO;
  238.     self.logoRigthDownView.hidden = NO;
  239.     self.logoLeftDownView.hidden = NO;
  240.    
  241.     self.logoMView.hidden = NO;
  242.     self.logoGetView.hidden = NO;
  243.     self.logoEetView.hidden = NO;
  244.    
  245.     [self performSelector:@selector(backAnimateGet) withObject:nil afterDelay:0.05f];
  246.     [self performSelector:@selector(backAnimateRotate) withObject:nil afterDelay:0.2f];
  247.     [self performSelector:@selector(backAnimateEet) withObject:nil afterDelay:0.15f];
  248. }
  249.  
  250. - (void)stopActivityIndication {
  251.    
  252.     _animationType = ABack;
  253. }
  254.  
  255. #pragma mark - Animation stages
  256.  
  257. - (void)animateStage1 {
  258.    
  259.     CGFloat width = self.logoLeftUpView.bounds.size.width;
  260.     CGFloat height = self.logoLeftUpView.bounds.size.height;
  261.     CGPoint center = CGPointMake(self.circleView.bounds.size.width / 2.f, self.circleView.bounds.size.height / 2.f);
  262.    
  263.     self.logoLeftUpView.bounds = CGRectMake(0.f, 0.f, width * 0.3f, height * 0.3f);
  264.     self.logoLeftUpView.center = center;
  265.     self.logoLeftUpView.alpha = 0.5f;
  266.     self.logoLeftUpView.hidden = NO;
  267.    
  268.     [UIView animateWithDuration:0.5f
  269.                           delay:0.f
  270.          usingSpringWithDamping:0.4f
  271.           initialSpringVelocity:0.8f
  272.                         options:UIViewAnimationOptionCurveEaseOut
  273.                      animations:^{
  274.                          
  275.                          self.logoLeftUpView.bounds = CGRectMake(0.f, 0.f, width, height);
  276.                          self.logoLeftUpView.center = center;
  277.                          self.logoLeftUpView.alpha = 1.0f;
  278.                      }
  279.                      completion:^(BOOL finished) {
  280.                          //[self animateStage5];
  281.                      }];
  282.    
  283. }
  284.  
  285. - (void)animateStage2 {
  286.    
  287.     CGFloat width = self.logoRightUpView.bounds.size.width;
  288.     CGFloat height = self.logoRightUpView.bounds.size.height;
  289.     CGPoint center = CGPointMake(self.circleView.bounds.size.width / 2.f, self.circleView.bounds.size.height / 2.f);
  290.    
  291.     self.logoRightUpView.bounds = CGRectMake(0.f, 0.f, width * 0.3f, height * 0.3f);
  292.     self.logoRightUpView.center = center;
  293.     self.logoRightUpView.alpha = 0.5f;
  294.     self.logoRightUpView.hidden = NO;
  295.    
  296.     [UIView animateWithDuration:0.5f
  297.                           delay:0.f
  298.          usingSpringWithDamping:0.4f
  299.           initialSpringVelocity:0.8f
  300.                         options:UIViewAnimationOptionCurveEaseOut
  301.                      animations:^{
  302.                          
  303.                          self.logoRightUpView.bounds = CGRectMake(0.f, 0.f, width, height);
  304.                          self.logoRightUpView.center = center;
  305.                          self.logoRightUpView.alpha = 1.0f;
  306.                      }
  307.                      completion:^(BOOL finished) {
  308.                          
  309.                      }];
  310.    
  311. }
  312.  
  313. - (void)animateStage3 {
  314.    
  315.     CGFloat width = self.logoRigthDownView.bounds.size.width;
  316.     CGFloat height = self.logoRigthDownView.bounds.size.height;
  317.     CGPoint center = CGPointMake(self.circleView.bounds.size.width / 2.f, self.circleView.bounds.size.height / 2.f);
  318.    
  319.     self.logoRigthDownView.bounds = CGRectMake(0.f, 0.f, width * 0.3f, height * 0.3f);
  320.     self.logoRigthDownView.center = center;
  321.     self.logoRigthDownView.alpha = 0.5f;
  322.     self.logoRigthDownView.hidden = NO;
  323.    
  324.     [UIView animateWithDuration:0.5f
  325.                           delay:0.f
  326.          usingSpringWithDamping:0.4f
  327.           initialSpringVelocity:0.8f
  328.                         options:UIViewAnimationOptionCurveEaseOut
  329.                      animations:^{
  330.                          
  331.                          self.logoRigthDownView.bounds = CGRectMake(0.f, 0.f, width, height);
  332.                          self.logoRigthDownView.center = center;
  333.                          self.logoRigthDownView.alpha = 1.0f;
  334.                      }
  335.                      completion:^(BOOL finished) {
  336.                          
  337.                      }];
  338.    
  339. }
  340.  
  341. - (void)animateStage4 {
  342.    
  343.     CGFloat width = self.logoLeftDownView.bounds.size.width;
  344.     CGFloat height = self.logoLeftDownView.bounds.size.height;
  345.     CGPoint center = CGPointMake(self.circleView.bounds.size.width / 2.f, self.circleView.bounds.size.height / 2.f);
  346.    
  347.     self.logoLeftDownView.bounds = CGRectMake(0.f, 0.f, width * 0.3f, height * 0.3f);
  348.     self.logoLeftDownView.center = center;
  349.     self.logoLeftDownView.alpha = 0.5f;
  350.     self.logoLeftDownView.hidden = NO;
  351.    
  352.     [UIView animateWithDuration:0.5f
  353.                           delay:0.f
  354.          usingSpringWithDamping:0.4f
  355.           initialSpringVelocity:0.8f
  356.                         options:UIViewAnimationOptionCurveEaseOut
  357.                      animations:^{
  358.                          
  359.                          self.logoLeftDownView.bounds = CGRectMake(0.f, 0.f, width, height);
  360.                          self.logoLeftDownView.center = center;
  361.                          self.logoLeftDownView.alpha = 1.0f;
  362.                      }
  363.                      completion:^(BOOL finished) {
  364.                          
  365.                      }];
  366.    
  367. }
  368.  
  369. /*
  370. - (void)runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
  371. {
  372.     CABasicAnimation* rotationAnimation;
  373.     rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
  374.     rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * rotations * duration ];
  375.     rotationAnimation.duration = duration;
  376.     rotationAnimation.cumulative = YES;
  377.     rotationAnimation.repeatCount = repeat;
  378.    
  379.     [view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
  380. }
  381.  
  382. - (void)rotateView:(UIView *)view
  383. {
  384.     [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
  385.        
  386.         [view setTransform:CGAffineTransformRotate(view.transform, M_PI_2)];
  387.        
  388.     }completion:^(BOOL finished) {
  389.        
  390.         if (finished) {
  391.             [self rotateView:view];
  392.         }
  393.     }];
  394. } */
  395.  
  396. - (void)animateStage5 {
  397.     //rotate cicleView left on 30 degrees
  398.     if (self.stopAction) {
  399.         [self performSelector:@selector(stopComplete) withObject:nil afterDelay:0.3f];
  400.         return;
  401.     }
  402.    
  403.     [UIView animateWithDuration:0.35f
  404.                           delay:0.f
  405.                         options:UIViewAnimationOptionCurveEaseInOut
  406.                      animations:^{
  407.                          
  408.                          [self.circleView setTransform:CGAffineTransformRotate(self.circleView.transform, (M_PI * -45.f)/180.f)];
  409.                          
  410.                      }completion:^(BOOL finished) {
  411.                          if (self.stopAction) {
  412.                              [self stopComplete];
  413.                              return;
  414.                          }
  415.                          [self animateStage6];
  416.                          if (_animationType == AStart) {
  417.                              //[self animateMStage1];
  418.                              [self performSelector:@selector(animateMStage1) withObject:nil afterDelay:0.15f];
  419.                          }
  420.                      }];
  421.    
  422. }
  423.  
  424. - (void)animateStage6 {
  425.     //start rotation cicleView right 390 degrees UIViewAnimationOptionCurveEaseIn
  426.     [UIView animateWithDuration:0.35f
  427.                           delay:0.f
  428.                         options:UIViewAnimationOptionCurveEaseIn
  429.                      animations:^{
  430.                          
  431.                          [self.circleView setTransform:CGAffineTransformRotate(self.circleView.transform, (M_PI * 45.f)/180.f)];
  432.                          
  433.                      }completion:^(BOOL finished) {
  434.                          
  435.                          if (self.stopAction) {
  436.                              [self stopComplete];
  437.                              return;
  438.                          }
  439.                          [self animateStage7];
  440.                          
  441.                          //if (_animationType == AStart) {
  442.                          //    [self animateMStage1];
  443.                          //}
  444.                      }];
  445. }
  446.  
  447. - (void)animateStage7 {
  448.     //middle on rotation cicleView right 390 degrees UIViewAnimationOptionCurveLinear
  449.     [UIView animateWithDuration:0.15f
  450.                           delay:0.f
  451.                         options:UIViewAnimationOptionCurveLinear
  452.                      animations:^{
  453.                          
  454.                          [self.circleView setTransform:CGAffineTransformRotate(self.circleView.transform, M_PI)];
  455.                          
  456.                      }completion:^(BOOL finished) {
  457.                          
  458.                          if (self.stopAction) {
  459.                              [self stopComplete];
  460.                              return;
  461.                          }
  462.                          [self animateStage8];
  463.                          //[self animateMStage1];
  464.                      }];
  465. }
  466. - (void)animateStage8 {
  467.     //middle on rotation cicleView right 390 degrees UIViewAnimationOptionCurveLinear
  468.     [UIView animateWithDuration:0.15f
  469.                           delay:0.f
  470.                         options:UIViewAnimationOptionCurveLinear
  471.                      animations:^{
  472.                          
  473.                          [self.circleView setTransform:CGAffineTransformRotate(self.circleView.transform, M_PI)];
  474.                          
  475.                      }completion:^(BOOL finished) {
  476.                          
  477.                          if (self.stopAction) {
  478.                              [self stopComplete];
  479.                              return;
  480.                          }
  481.                          if (_animationType == AActivity) {
  482.                              [self animateStage8];
  483.                          } else {
  484.                              [self animateStage9];
  485.                          }
  486.                          
  487.                      }];
  488. }
  489.  
  490. - (void)animateStage9 {
  491.     //end rotation cicleView right 390 degrees UIViewAnimationOptionCurveEaseOut
  492.     [UIView animateWithDuration:0.3f
  493.                           delay:0.f
  494.                         options:UIViewAnimationOptionCurveEaseOut
  495.                      animations:^{
  496.                          
  497.                          [self.circleView setTransform:CGAffineTransformRotate(self.circleView.transform, (M_PI * 45.f)/180.f)];
  498.                          
  499.                      }completion:^(BOOL finished) {
  500.                          
  501.                          if (self.stopAction) {
  502.                              [self stopComplete];
  503.                              return;
  504.                          }
  505.                          [self animateStage10];
  506.                      }];
  507. }
  508.  
  509. - (void)animateStage10 {
  510.     //rotate cicleView left on 30 degrees
  511.     [UIView animateWithDuration:0.4f
  512.                           delay:0.f
  513.                         options:UIViewAnimationOptionCurveEaseInOut
  514.                      animations:^{
  515.                          
  516.                          [self.circleView setTransform:CGAffineTransformRotate(self.circleView.transform, (M_PI * -45.f)/180.f)];
  517.                          
  518.                      }completion:^(BOOL finished) {
  519.                          
  520.                          if (_animationType == ABack) {
  521.                              [self stopComplete];
  522.                          } else if (_animationType == AHalfStart) {
  523.                              [self animateGet];
  524.                          }
  525.                      }];
  526.    
  527. }
  528.  
  529. - (void)animateMStage1 {
  530.    
  531.     CGFloat width = self.logoMView.bounds.size.width;
  532.     CGFloat height = self.logoMView.bounds.size.height;
  533.     CGPoint center = CGPointMake(self.bounds.size.width / 2.f, self.bounds.size.height / 2.f);
  534.     self.logoMView.bounds = CGRectMake(0.f, 0.f, width * 0.25f, height * 0.25f);
  535.     self.logoMView.center = center;
  536.     self.logoMView.alpha = 0.1f;
  537.     self.logoMView.hidden = NO;
  538.    
  539.     [UIView animateWithDuration:0.2f
  540.                           delay:0.f
  541.                         options:UIViewAnimationOptionCurveLinear
  542.                      animations:^{
  543.                          
  544.                          self.logoMView.alpha = 0.5f;
  545.                          self.logoMView.bounds = CGRectMake(0.f, 0.f, width * 0.5f, height * 0.5f);
  546.                          self.logoMView.center = center;
  547.                          [self.logoMView setTransform:CGAffineTransformRotate(self.logoMView.transform, M_PI)];
  548.                          
  549.                      }completion:^(BOOL finished) {
  550.                          
  551.                          if (self.stopAction) {
  552.                              self.logoMView.bounds = CGRectMake(0.f, 0.f, width, height);
  553.                              self.logoMView.center = center;
  554.                              [self stopComplete];
  555.                              return;
  556.                          }
  557.                          
  558.                          [UIView animateWithDuration:0.2f
  559.                                                delay:0.f
  560.                                              options:UIViewAnimationOptionCurveLinear
  561.                                           animations:^{
  562.                                               self.logoMView.alpha = 1.0f;
  563.                                               self.logoMView.bounds = CGRectMake(0.f, 0.f, width * 0.75f, height * 0.75f);
  564.                                               self.logoMView.center = center;
  565.                                               [self.logoMView setTransform:CGAffineTransformRotate(self.logoMView.transform, M_PI)];
  566.                                              
  567.                                           }completion:^(BOOL finished) {
  568.                                              
  569.                                               if (self.stopAction) {
  570.                                                   self.logoMView.bounds = CGRectMake(0.f, 0.f, width, height);
  571.                                                   self.logoMView.center = center;
  572.                                                   [self stopComplete];
  573.                                                   return;
  574.                                               }
  575.                                              
  576.                                               [UIView animateWithDuration:0.25f
  577.                                                                     delay:0.f
  578.                                                                   options:UIViewAnimationOptionCurveLinear
  579.                                                                animations:^{
  580.                                                                    
  581.                                                                    self.logoMView.bounds = CGRectMake(0.f, 0.f, width, height);
  582.                                                                    self.logoMView.center = center;
  583.                                                                    [self.logoMView setTransform:CGAffineTransformRotate(self.logoMView.transform, M_PI)];
  584.                                                                    
  585.                                                                }completion:^(BOOL finished) {
  586.                                                                    
  587.                                                                    //[self animateMStage2];
  588.                                                                    
  589.                                                                    if (self.stopAction) {
  590.                                                                        [self stopComplete];
  591.                                                                        return;
  592.                                                                    }
  593.                                                                    
  594.                                                                    [UIView animateWithDuration:0.25f
  595.                                                                                          delay:0.f
  596.                                                                                        options:UIViewAnimationOptionCurveLinear
  597.                                                                                     animations:^{
  598.                                                                                        
  599.                                                                                         [self.logoMView setTransform:CGAffineTransformRotate(self.logoMView.transform, M_PI)];
  600.                                                                                        
  601.                                                                                     }completion:^(BOOL finished) {
  602.                                                                                        
  603.                                                                                         if (self.stopAction) {
  604.                                                                                             [self stopComplete];
  605.                                                                                             return;
  606.                                                                                         }
  607.                                                                                        
  608.                                                                                         [self animateMStage2];
  609.                                                                                     }];
  610.                                                                    
  611.                                                                    
  612.                                                                }];
  613.                                              
  614.                                           }];
  615.  
  616.                      }];
  617. }
  618.  
  619. - (void)animateMStage2 {
  620.    
  621.     [self animateGet];
  622.     [UIView animateWithDuration:0.20f
  623.                           delay:0.f
  624.                         options:UIViewAnimationOptionCurveEaseOut
  625.                      animations:^{
  626.                          
  627.                          [self.logoMView setTransform:CGAffineTransformRotate(self.logoMView.transform, (M_PI * 45.f)/180.f)];
  628.                          
  629.                      }completion:^(BOOL finished) {
  630.                          
  631.                          if (self.stopAction) {
  632.                              [self stopComplete];
  633.                              return;
  634.                          }
  635.                          
  636.                          [self animateMStage3];
  637.                      }];
  638. }
  639.  
  640. - (void)animateMStage3 {
  641.    
  642.     [UIView animateWithDuration:0.20f
  643.                           delay:0.f
  644.                         options:UIViewAnimationOptionCurveEaseInOut
  645.                      animations:^{
  646.                          
  647.                          [self.logoMView setTransform:CGAffineTransformRotate(self.logoMView.transform, (M_PI * -45.f)/180.f)];
  648.                          
  649.                      }completion:^(BOOL finished) {
  650.                          
  651.                          //[self animateStage10];
  652.                          //[self performSelector:@selector(stopComplete) withObject:nil afterDelay:0.1f];
  653.                      }];
  654. }
  655.  
  656. - (void)animateGet {
  657.     [self performSelector:@selector(animateEet) withObject:nil afterDelay:0.15f];
  658.    
  659.     CGFloat width = self.logoGetView.bounds.size.width;
  660.     CGFloat height = self.logoGetView.bounds.size.height;
  661.     CGPoint center = CGPointMake(self.bounds.size.width / 2.f, self.bounds.size.height / 2.f);
  662.     self.logoGetView.bounds = CGRectMake(0.f, 0.f, width * 0.25f, height * 0.25f);
  663.     self.logoGetView.center = center;
  664.     self.logoGetView.alpha = 0.25f;
  665.     self.logoGetView.hidden = NO;
  666.    
  667.     [UIView animateWithDuration:0.25f
  668.                           delay:0.f
  669.                         options:UIViewAnimationOptionCurveEaseOut//UIViewAnimationOptionCurveLinear
  670.                      animations:^{
  671.                          
  672.                          self.logoGetView.bounds = CGRectMake(0.f, 0.f, width, height);
  673.                          self.logoGetView.center = center;
  674.                          self.logoGetView.alpha = 1.f;
  675.                          
  676.                      }completion:^(BOOL finished) {
  677.                          
  678.                      }];
  679.    
  680. }
  681.  
  682. - (void)animateEet {
  683.    
  684.     CGFloat width = self.logoEetView.bounds.size.width;
  685.     CGFloat height = self.logoEetView.bounds.size.height;
  686.     CGPoint center = CGPointMake(self.bounds.size.width / 2.f, self.bounds.size.height / 2.f);
  687.     self.logoEetView.bounds = CGRectMake(0.f, 0.f, width * 0.25f, height * 0.25f);
  688.     self.logoEetView.center = center;
  689.     self.logoEetView.alpha = 0.25f;
  690.     self.logoEetView.hidden = NO;
  691.    
  692.     [UIView animateWithDuration:0.25f
  693.                           delay:0.f
  694.                         options:UIViewAnimationOptionCurveEaseOut//UIViewAnimationOptionCurveLinear
  695.                      animations:^{
  696.                          
  697.                          self.logoEetView.bounds = CGRectMake(0.f, 0.f, width, height);
  698.                          self.logoEetView.center = center;
  699.                          self.logoEetView.alpha = 1.f;
  700.                          
  701.                      }completion:^(BOOL finished) {
  702.                          [self performSelector:@selector(stopComplete) withObject:nil afterDelay:0.3f];
  703.                      }];
  704. }
  705.  
  706. - (void)backAnimateGet {
  707.     CGFloat width = self.logoGetView.bounds.size.width;
  708.     CGFloat height = self.logoGetView.bounds.size.height;
  709.     CGPoint center = CGPointMake(self.bounds.size.width / 2.f, self.bounds.size.height / 2.f);
  710.    
  711.     self.logoGetView.bounds = CGRectMake(0.f, 0.f, width, height);
  712.     self.logoGetView.center = center;
  713.     self.logoGetView.alpha = 1.f;
  714.     self.logoGetView.hidden = NO;
  715.    
  716.     [UIView animateWithDuration:0.3f
  717.                           delay:0.f
  718.                         options:UIViewAnimationOptionCurveLinear
  719.                      animations:^{
  720.                          
  721.                          self.logoGetView.bounds = CGRectMake(0.f, 0.f, width * 0.15f, height * 0.15f);
  722.                          self.logoGetView.center = center;
  723.                          self.logoGetView.alpha = 0.1f;
  724.                          
  725.                      }completion:^(BOOL finished) {
  726.                          
  727.                          //hide and restore size
  728.                          self.logoGetView.hidden = YES;
  729.                          self.logoGetView.bounds = CGRectMake(0.f, 0.f, width, height);
  730.                          self.logoGetView.center = center;
  731.                          self.logoGetView.alpha = 1.f;
  732.                      }];
  733. }
  734.  
  735. - (void)backAnimateEet {
  736.     CGFloat width = self.logoEetView.bounds.size.width;
  737.     CGFloat height = self.logoEetView.bounds.size.height;
  738.     CGPoint center = CGPointMake(self.bounds.size.width / 2.f, self.bounds.size.height / 2.f);
  739.    
  740.     self.logoEetView.bounds = CGRectMake(0.f, 0.f, width, height);
  741.     self.logoEetView.center = center;
  742.     self.logoEetView.alpha = 1.f;
  743.     self.logoEetView.hidden = NO;
  744.    
  745.     [UIView animateWithDuration:0.3f
  746.                           delay:0.f
  747.                         options:UIViewAnimationOptionCurveLinear
  748.                      animations:^{
  749.                          
  750.                          self.logoEetView.bounds = CGRectMake(0.f, 0.f, width * 0.15f, height * 0.15f);
  751.                          self.logoEetView.center = center;
  752.                          self.logoEetView.alpha = 0.1f;
  753.                          
  754.                      }completion:^(BOOL finished) {
  755.                          
  756.                          //hide and restore size
  757.                          self.logoEetView.hidden = YES;
  758.                          self.logoEetView.bounds = CGRectMake(0.f, 0.f, width, height);
  759.                          self.logoEetView.center = center;
  760.                          self.logoEetView.alpha = 1.f;
  761.                      }];
  762. }
  763.  
  764. - (void)backAnimateRotate {
  765.    
  766.     [self animateStage5];
  767. }
  768.  
  769.  
  770. - (void)stopComplete {
  771.    
  772.     //self.isAnimating = NO;
  773.     self.stopAction = NO;
  774.    
  775.     if (_animationType == AStart || _animationType == AHalfStart) {
  776.        
  777.         self.logoLeftUpView.hidden = YES;
  778.         self.logoRightUpView.hidden = YES;
  779.         self.logoRigthDownView.hidden = YES;
  780.         self.logoLeftDownView.hidden = YES;
  781.        
  782.         self.logoMView.hidden = YES;
  783.         self.logoGetView.hidden = YES;
  784.         self.logoEetView.hidden = YES;
  785.        
  786.         self.logoCompleteView.hidden = NO;
  787.     }
  788.    
  789.     [self.logoLeftUpView setTransform:CGAffineTransformIdentity];
  790.     [self.logoRightUpView setTransform:CGAffineTransformIdentity];
  791.     [self.logoRigthDownView setTransform:CGAffineTransformIdentity];
  792.     [self.logoLeftDownView setTransform:CGAffineTransformIdentity];
  793.    
  794.     [self.logoMView setTransform:CGAffineTransformIdentity];
  795.    
  796.     _animationType = ANone;
  797.    
  798.     if (self.animateBackWhenStopped) {
  799.         self.animateBackWhenStopped = NO;
  800.         [self backAnimation];
  801.     } else if (self.animateStartWhenStopped) {
  802.         self.animateStartWhenStopped = NO;
  803.         [self startAnimation];
  804.     }
  805. }
  806.  
  807. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement