I see different examples where constraints are set. Some set them in viewDidLoad / loadView (after the subview was added). Others set them in the m
viewDidLoad
loadView
You can set them in viewWillLayoutSubviews: too:
override func viewWillLayoutSubviews() { if(!wasViewLoaded){ wasViewLoaded = true //update constraint //also maybe add a subview } }