title: iPhone - UINavigationController - custom animation with CATransaction
body: <p>I am trying to create a category for UINavigationController so I can put together a few custom animations. I came across <a href="https://stackoverflow.com/questions/3332383/animating-uinavigationcontrollers-back-button">this question</a> and it got me started. I've come up with the following for a push function:</p>
  
  <pre><code>- (void)pushViewControllerMoveInFromBottom:(UIViewController *)viewController {
      [CATransaction begin];
      CATransition *transition;
      transition = [CATransition animation];
      transition.type = kCATransitionMoveIn;
      transition.subtype = kCATransitionFromBottom;
      transition.duration = 0.7;
  
      [CATransaction setValue:(id)kCFBooleanTrue
                       forKey:kCATransactionDisableActions];
  
      [[[[self.view subviews] objectAtIndex:0] layer] addAnimation:transition forKey:nil];
      [self  pushViewController:viewController animated:YES];
      [CATransaction commit];
  }
  </code></pre>
  
  <p>I don't understand which view/layer is being accessed via the subview call. So if someone could help me understand that, that would be helpful. It seems to be effecting whatever view is about to come onto the screen.</p>
  
  <p>But <strong>my main question is that I'm trying to create a pop that will "undo" the above function.</strong> For clarity sake, lets say I have two views, A and B. A is the first view that is shown on the screen. The function above, will move in B without pushing A out. Much like a modal view would. But the function below slides A back in over B, rather that sliding B up and leaving A in place.</p>
  
  <pre><code>- (void)popViewControllerMoveInFromTop {
      [CATransaction begin];
      CATransition *transition;
      transition = [CATransition animation];
      transition.type = kCATransitionMoveIn;
      transition.subtype = kCATransitionFromTop;
      transition.duration = 0.7;
  
      [CATransaction setValue:(id)kCFBooleanTrue
                       forKey:kCATransactionDisableActions];
  
      [[[[self.view subviews] objectAtIndex:0] layer] addAnimation:transition forKey:nil];
      [self  popViewControllerAnimated:YES];    
      [CATransaction commit];
  }
  </code></pre>
  
  <p>I don't want to use a modal view and I would rather not use custom animation blocks to change the frame of the views.</p>