Instance Method

updateViewConstraints()

Called when the view controller'€™s view needs to update its constraints.

Declaration

func updateViewConstraints()

Discussion

Override this method to optimize changes to your constraints.

To schedule a change, call setNeedsUpdateConstraints() on the view. The system then calls your implementation of updateViewConstraints() before the layout occurs. This lets you verify that all necessary constraints for your content are in place at a time when your properties are not changing.

Your implementation must be as efficient as possible. Do not deactivate all your constraints, then reactivate the ones you need. Instead, your app must have some way of tracking your constraints, and validating them during each update pass. Only change items that need to be changed. During each update pass, you must ensure that you have the appropriate constraints for the app’s current state.

Do not call setNeedsUpdateConstraints() inside your implementation. Calling setNeedsUpdateConstraints() schedules another update pass, creating a feedback loop.

See Also

Configuring the View’s Layout Behavior

var edgesForExtendedLayout: UIRectEdge

The edges that you extend for your view controller.

struct UIRectEdge

Constants that specify the edges of a rectangle.

var extendedLayoutIncludesOpaqueBars: Bool

A Boolean value indicating whether or not the extended layout includes opaque bars.

func viewWillLayoutSubviews()

Called to notify the view controller that its view is about to layout its subviews.

func viewDidLayoutSubviews()

Called to notify the view controller that its view has just laid out its subviews.