Objective-C/Swift (iOS) When are the auto-constraints applied in the View/ViewController work flow?
The constraints are applied in the layoutSubviews
method. So if you want to do something after they are applied in a UIView
subclass, override the method:
override func layoutSubviews() {
super.layoutSubviews()
//the frames have now their final values, after applying constraints
}
In a UIViewController
subclass, use viewDidLayoutSubviews
for the same purpose:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
//the frames have now their final values, after applying constraints
}
Please note that you shouldn't set frame
/ bounds
for a view if you added auto layout constraints to this view.