Enumeration

NSStackView.Gravity

The various gravity areas available in a stack view.

Declaration

enum Gravity : Int

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 NSLayoutPriorityDefaultLow. For information about geometric spacing between gravity areas, see the description of the spacing property.

Topics

Constants

case top

The topmost gravity area in a vertically oriented stack view.

static var leading: NSStackView.Gravity

The leftmost or rightmost gravity area in a horizontally oriented stack view, depending on the user interface language or on the explicitly set user interface layout direction.

case center

The center gravity area, regardless of stack view layout direction and regardless of the user interface language.

case bottom

The bottommost gravity area in a vertically oriented stack view.

static var trailing: NSStackView.Gravity

The leftmost or rightmost gravity area in a horizontally oriented stack view, depending on the user interface language or on the explicitly set user interface layout direction.