Contents

viewWillLayoutSubviews()

Notifies the view controller that its view is about to lay out its subviews.

Declaration

func viewWillLayoutSubviews()

Mentioned in

Discussion

When a view’s bounds change, the view adjusts the position of its subviews. Your view controller can override this method to make changes before the view lays out its subviews. The default implementation of this method does nothing.

In iOS 18 and later, UIKit supports automatic trait tracking inside this method for traits from this view controller’s traitCollection and the traitCollection of its view. For more information, see Automatic trait tracking.

This method supports automatic observation tracking. For more information, see Updating views automatically with observation tracking.

See Also

Observing data in view controllers