title: How to stop and reverse a UIView animation?
body: <p>I have animated a UIView so that it shrinks when the user touches a toggle button and it expands back to its original size when the user touches the button again. So far everything works just fine. The problem is that the animation takes some time - e.g. 3 seconds. During that time I still want the user to be able to interact with the interface. So when the user touches the button again while the animation is still in progress the animation is supposed to stop right where it is and reverse.</p>
  
  <p>In the Apple Q&amp;As I have found a way to pause all animations immediately:</p>
  
  <p><a href="https://developer.apple.com/library/ios/#qa/qa2009/qa1673.html">https://developer.apple.com/library/ios/#qa/qa2009/qa1673.html</a></p>
  
  <p>But I do not see a way to reverse the animation from here (and omit the rest of the initial animation). How do I accomplish this?</p>
  
  <pre><code>- (IBAction)toggleMeter:(id)sender {
      if (self.myView.hidden) {        
          self.myView.hidden = NO;
          [UIView animateWithDuration:3 animations:^{
              self.myView.transform = expandMatrix;
          } completion:nil];
      } else {
          [UIView animateWithDuration:3 animations:^{
              self.myView.transform = shrinkMatrix;
          } completion:^(BOOL finished) {
              self.myView.hidden = YES;
          }];
      }
  }
  </code></pre>