Created
May 4, 2018 01:19
-
-
Save alfian0/937eb41fdba0446d0831a2ece42d3889 to your computer and use it in GitHub Desktop.
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
| extension UIViewController { | |
| func add(_ child: UIViewController) { | |
| addChildViewController(child) | |
| view.addSubview(child.view) | |
| child.view.frame = view.bounds | |
| child.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
| child.didMove(toParentViewController: self) | |
| } | |
| func remove(_ child: UIViewController) { | |
| child.willMove(toParentViewController: nil) | |
| child.view.removeFromSuperview() | |
| child.removeFromParentViewController() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment