Advertisement
Guest User

Untitled

a guest
Jan 9th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)perform {
  2.     // Get a hold of the controllers
  3.     UIViewController *toController = self.destinationViewController;
  4.     UIViewController *fromController = self.sourceViewController;
  5.     UIViewController *containerController = fromController.parentViewController;
  6.     // Get hold of the views
  7.     UIView *toView = toController.view;
  8.     UIView *fromView = fromController.view;
  9.     UIView *containerView = fromView.superview;
  10.     // Tell both controllers that the transition is begining
  11.     [toController beginAppearanceTransition:YES animated:YES];
  12.     [fromController beginAppearanceTransition:NO animated:YES];
  13.     // Add the controller as a child controller
  14.     [containerController addChildViewController:toController];
  15.     // Make sure that the to view is in the correct position
  16.     toView.frame = fromView.frame;
  17.     // Add the new view to the back of the container view
  18.     [containerView insertSubview:toView belowSubview:fromView];
  19.     // Animate the old view down
  20.     [UIView animateWithDuration:0.35
  21.                           delay:0.0
  22.                         options:UIViewAnimationOptionCurveEaseInOut
  23.                      animations:^{
  24.                          CGRect frame = fromView.frame;
  25.                          frame.origin.y = containerView.bounds.size.height;
  26.                          fromView.frame = frame;
  27.                      }
  28.                      completion:^(BOOL finished) {
  29.                          // Tell the new controller that it has moved
  30.                          [toController didMoveToParentViewController:containerController];
  31.                          // Remove the old view and controller
  32.                          [fromController willMoveToParentViewController:nil];
  33.                          [fromView removeFromSuperview];
  34.                          [fromController removeFromParentViewController];
  35.                          // Tell the controllers that the transition has finished
  36.                          [toController endAppearanceTransition];
  37.                          [fromController endAppearanceTransition];
  38.                      }];
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement