Instance Property


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


var directionalLayoutMargins: NSDirectionalEdgeInsets { get set }


Use this property to specify the desired amount of space (measured in points) between the edge of the view and any subviews. During layout, this property takes into account whether the current language is left-to-right or right-to-left.

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 leading and trailing 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.

The default margins are eight points on each side.

If the view is a view controller’s root view, the system sets and manages the margins. The top and bottom margins are set to zero points. The leading and trailing margins vary depending on the current size class, but can be either 16 or 20 points. You cannot change these margins.

See Also

Configuring Content Margins

var layoutMargins: UIEdgeInsets

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

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software