How to subview a ViewController with a ViewController

April 09, 2020

To add a ViewController

addChild(childVC)
parentVC.subview(childVC.view)
childVC.didMove(toParent: self)

To remove a ViewController

childVC.willMove(toParent: nil)
childVC.view.removeFromSuperview()
childVC.removeFromParent()