Instance Property


The default spacing to use when laying out content in the view.


var layoutMargins: UIEdgeInsets { get set }


In iOS 11 and later, use the directionalLayoutMargins property to specify layout margins instead of this property. The leading and trailing edge insets in the directionalLayoutMargins property are synchronized with the left and right insets in this property. For example, setting the leading directional edge inset to 20 points causes the left inset of this property to be set to 20 points on a system with a left-to-right language.

For most views, the default layout margins are 8 points on each side. You can change these values as needed for your interface.

For the root view of a view controller, this property is set to 0 points on each side. The actual margins are obtained by adding the values in this property to the values in the systemMinimumLayoutMargins property. To eliminate the system minimum margins, set the viewRespectsSystemMinimumLayoutMargins property to false.

This property specifies the desired amount of space (measured in points) between the edge of the view and any subviews. Auto layout uses your margins as a cue for placing content. For example, if you specify a set of horizontal constraints using the format string “|-[subview]-|”, the left and right edges of the subview are inset from the edge of the superview by the corresponding layout margins. When the edge of your view is close to the edge of the superview and the preservesSuperviewLayoutMargins property is true, the actual layout margins may be increased to prevent content from overlapping the superview’s margins.

See Also

Configuring Content Margins

var directionalLayoutMargins: NSDirectionalEdgeInsets

The default spacing to use when laying out content in a view, taking into account the current language direction.

var preservesSuperviewLayoutMargins: Bool

A Boolean value indicating whether the current view also respects the margins of its superview.

func layoutMarginsDidChange()

Notifies the view that the layout margins changed.