Contents

NSStackView.Gravity

The gravity areas available in a stack view.

Declaration

enum Gravity

Overview

The layout of a stack view is partitioned into three distinct areas in which you can place views. These are known as gravity areas. You can use these constants to configure a stack view by way of the insertView(_:at:in:) and setViews(_:in:) methods.

In a horizontally oriented stack view, the three gravity areas are leading, NSStackView.Gravity.center, and trailing. The ordering of these areas depends on the user interface language, unless you’ve explicitly specified the stack view’s user interface layout direction by calling the inherited userInterfaceLayoutDirection method. For a userInterfaceLayoutDirection property value of NSUserInterfaceLayoutDirection.leftToRight, the leading gravity area is on the left.

In a vertically oriented stack view, the three gravity areas are always NSStackView.Gravity.top, NSStackView.Gravity.center, and NSStackView.Gravity.bottom.

The center gravity area is constrained to remain geometrically centered with an Auto Layout priority of defaultLow. For information about geometric spacing between gravity areas, see the description of the spacing property.

Topics

Constants

Initializers

See Also

Managing Views in Gravity Areas