title: How to make UIView animation callback on reverse?
body: <p>I've been trying to make a short animation that reverses halfway through with a static method that can be called by my view controllers. This works fine.</p>
  
  <p>But I need it to perform a selector when the reverse takes place, essentially in the middle of the animation.  The method setAnimationDidStopSelector only fires when the entire animation is completed, not in the middle.</p>
  
  <p>So I split the animation into two blocks.  However, when I do this, the first animation is instantly completed, then the second one happens.  I suspect it's because the animation is on the same view.  Perhaps there can't be two separate animation blocks for the same view?</p>
  
  <p>I've set up the second block with a different animation name, and with the appropriate delay, and even tried setAnimationBeginsFromCurrentState (even though it's discouraged in OS 4), but none seem to solve the problem.</p>
  
  <p>Here's some sample code to get an idea of one of the ways I've tried.  'selector' is the method I need called halfway through (once the alpha is transparent).</p>
  
  <pre><code>[UIView beginAnimations:name context:view];
  [UIView setAnimationDuration:(duration/2)];
  [UIView setAnimationDelegate:delegate];
  [UIView setAnimationDidStopSelector:selector];
  [view setAlpha:0.0];
  [UIView commitAnimations];
  
  name = [name stringByAppendingString:@"_reverse"];
  [UIView beginAnimations:name context:view];
  [UIView setAnimationDelay:(duration/2)];
  [UIView setAnimationDuration:(duration/2)];
  [UIView setAnimationDelegate:delegate];
  [UIView setAnimationDidStopSelector:selector];
  [view setAlpha:1.0];
  [UIView commitAnimations];
  </code></pre>
  
  <p>Edit:  I want to avoid animation 'blocks' as I'd like the code to be compatible with pre-OS4. I'd also like to keep the method static so I can use it as a library method.</p>