Last active
October 18, 2017 18:31
-
-
Save ariok/7706798 to your computer and use it in GitHub Desktop.
Add/Remove a single child ViewController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Remove child controllers to a custom container controller with Animations | |
// ADD THE CHILD CONTROLLER | |
self.childController = theChildController; | |
self.childController.view.frame = setupInitialChildControllerFrame(); | |
[self addChildViewController:self.childController]; | |
[self.view addSubview:self.childController.view]; | |
[self.childController didMoveToParentViewController:self]; | |
[UIView animateWithDuration:1.0 | |
delay:0.0 | |
usingSpringWithDamping:0.6 | |
initialSpringVelocity:0.3 | |
options:UIViewAnimationOptionCurveEaseIn | |
animations:^{ | |
self.childController.view.frame = setupFinalChildControllerFrame(); | |
} completion:nil | |
]; | |
// REMOVE THE CHILD CONTROLLER | |
[self.childController willMoveToParentViewController:nil]; | |
[UIView animateWithDuration:0.8 | |
delay:0.0 | |
usingSpringWithDamping:0.6 | |
initialSpringVelocity:0.3 | |
options:UIViewAnimationOptionCurveEaseIn | |
animations:^{ | |
self.childController.view.frame = setupInitialChildControllerFrame(); | |
} completion:^(BOOL complete){ | |
[self.childController removeFromParentViewController]; | |
self.childController = nil; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment