Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)perform {
- // Get a hold of the controllers
- UIViewController *toController = self.destinationViewController;
- UIViewController *fromController = self.sourceViewController;
- UIViewController *containerController = fromController.parentViewController;
- // Get hold of the views
- UIView *toView = toController.view;
- UIView *fromView = fromController.view;
- UIView *containerView = fromView.superview;
- // Tell both controllers that the transition is begining
- [toController beginAppearanceTransition:YES animated:YES];
- [fromController beginAppearanceTransition:NO animated:YES];
- // Add the controller as a child controller
- [containerController addChildViewController:toController];
- // Make sure that the to view is in the correct position
- toView.frame = fromView.frame;
- // Add the new view to the back of the container view
- [containerView insertSubview:toView belowSubview:fromView];
- // Animate the old view down
- [UIView animateWithDuration:0.35
- delay:0.0
- options:UIViewAnimationOptionCurveEaseInOut
- animations:^{
- CGRect frame = fromView.frame;
- frame.origin.y = containerView.bounds.size.height;
- fromView.frame = frame;
- }
- completion:^(BOOL finished) {
- // Tell the new controller that it has moved
- [toController didMoveToParentViewController:containerController];
- // Remove the old view and controller
- [fromController willMoveToParentViewController:nil];
- [fromView removeFromSuperview];
- [fromController removeFromParentViewController];
- // Tell the controllers that the transition has finished
- [toController endAppearanceTransition];
- [fromController endAppearanceTransition];
- }];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement