title: Flickering during custom view controller transition iOS 7
body: <p>I'm trying to do a very simple transition: one view moves half the screen to the left while the second ("to") view moves in half a screen.</p>
  
  <p>I have the animation working, but when I reverse the animation, I see a flickering. The "to" view (i.e. the original view) is visible at the origin of 0,0 although I set a different frame.</p>
  
  <p>I dumped the view hierarchy. The frames are set correctly (-100 0; 320 480 for the to view), but nonetheless it shows up at 0,0. Is a screenshot of the view cached somewhere for the animation?</p>
  
  <pre><code>- (void)animateTransition:(id&lt;UIViewControllerContextTransitioning&gt;)transitionContext
  {
  UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
  UIViewController *toViewController   = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
  
  UIView *container = [transitionContext containerView];
  
  CGRect offsetCoverRect    = CGRectMake(-100.0, 0.0, 320, 480);
  CGRect detailsRect        = CGRectMake(-100.0 + 320.0, 0.0, 320, 480);
  CGRect detailsOutsideRect = CGRectMake(320.0, 0.0, 320, 480);
  
  CGRect normalRect = CGRectMake(0.0, 0.0, 320, 480);
  
  
  if (self.revealDetails)
  {
      toViewController.view.frame = detailsOutsideRect;
      [container addSubview:toViewController.view];
  }
  else
  {
      [container insertSubview:toViewController.view belowSubview:fromViewController.view];
  
      // reversing… set the frame to the original offset (shows at 0,0 for a moment)
      toViewController.view.frame = offsetCoverRect;
  }
  
  [UIView animateKeyframesWithDuration:2 delay:0 options:0 animations:^{
  
      if (self.revealDetails)
      {
          fromViewController.view.frame = offsetCoverRect;
          toViewController.view.frame = detailsRect;
      }
      else
      {
          fromViewController.view.frame = detailsOutsideRect;
          toViewController.view.frame = normalRect;
      }
  } completion:^(BOOL finished) { [transitionContext completeTransition:finished]; }];
  }
  </code></pre>
  
  <p><strong>Update:</strong> </p>
  
  <p>It seems to be related to <code>UIModalPresentationCustom</code>. I need to use this so that the from view is not removed when the transition completes. However, it seems to assume that the from view controller for the reverse transition starts at 0,0.</p>
  
  <p><strong>Update 2:</strong> </p>
  
  <p>Very easy to reproduce with the following code:</p>
  
  <pre><code>UIView *snapshot = [containerView snapshotViewAfterScreenUpdates:NO];
  [containerView addSubview:snapshot];
  </code></pre>
  
  <p>The above will show the to view centered on screen, no matter what actual frame or center I set before the animation.</p>