Created
June 8, 2018 08:39
-
-
Save chriswill0w/0e7863206df8beccdaa6cb750eda8856 to your computer and use it in GitHub Desktop.
This file contains 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.didMove(toParentViewController: self) | |
} | |
func remove() { | |
guard parent != nil else { | |
return | |
} | |
willMove(toParentViewController: nil) | |
removeFromParentViewController() | |
view.removeFromSuperview() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment