title: Best way to handle a chain of animations with UIViewAnimations
body: <p>I am build an iOS application in which I have a requirement for the backgroundColor of the view to animation through a selection of colors. In my viewDidLoad method I am basically firing off a chain of UIView animations using the following.</p>
  
  <pre><code>-(void) beginFirstStageBackgroundAnimation
  {
      [UIView animateWithDuration: 3.0f
                            delay: 3.0f
                          options: UIViewAnimationOptionTransitionCrossDissolve
                       animations:^{
                           self.view.backgroundColor = [UIColor colorWithRed: 251./255 green:203./255 blue:147./255 alpha:1.0];
                       }
                       completion:^(BOOL finished){
                           [self secondStageBackgroundAnimation];
                       }
       ];
  }
  </code></pre>
  
  <p>The completion handler fires the second method containing the next color....</p>
  
  <pre><code>-(void) secondStageBackgroundAnimation
  {
      [UIView animateWithDuration: 3.0f
                            delay: 3.0f
                          options: UIViewAnimationOptionTransitionCrossDissolve
                       animations:^{
                           self.view.backgroundColor = [UIColor colorWithRed:251./255 green:224./255 blue:96./255 alpha:1.0];
                       }
                       completion:^(BOOL finished){
                           [self thirdStageBackgroundAnimation];
                       }
       ];
  }
  </code></pre>
  
  <p>And so on...this goes on until in the seventh animation I call <code>[self beginFirstStageBackgroundAnimation];</code> in the completion to begin the process again.</p>
  
  <p>When the I leave the view with the back button, in viewDidDisappear or when the timer on the display ends I run <code>[self.view.layer removeAllAnimations];</code> to entirely get rid of the animations. However, the app runs and works exactly as intended but seems to be crashing after leaving the view and running for a whole and although I don't know why yet it seems related to this animation chain.</p>
  
  <p>Is there a better solution to animate the backgroundColor of the view every 3 seconds with a 3 second delay? </p>
  
  <p>And does <code>[self.view.layer removeAllAnimations];</code> actually do what I want?</p>
  
  <p>EDIT: The code where I leave the view is as follows:</p>
  
  <pre><code>-(void) backBtnPressed:(id)sender
  {
      [self stopAudio]; // stop audio that is playing.
      [self.view.layer removeAllAnimations]; // remove all animations?
      [self.navigationController popViewControllerAnimated: YES]; // pop view from stack
  }
  </code></pre>