Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderBollbach/e2e3e7344999498afa6cc5a1026bb1da to your computer and use it in GitHub Desktop.
Save AlexanderBollbach/e2e3e7344999498afa6cc5a1026bb1da to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
class TestVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .green
}
}
let tvc = TestVC()
override func viewDidLoad() {
super.viewDidLoad()
addChild(tvc)
view.addSubview(tvc.view)
tvc.view.translatesAutoresizingMaskIntoConstraints = false
tvc.view.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
tvc.view.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
tvc.view.widthAnchor.constraint(equalToConstant: 200).isActive = true
tvc.view.heightAnchor.constraint(equalToConstant: 200).isActive = true
tvc.didMove(toParent: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment