Sets the Auto Layout priority for the stack view to minimize its size, for a specified user interface axis.
- macOS 10.9+
The horizontal or vertical user interface axis for which you’re setting the stack view’s hugging priority; one of the constants from the
Interface Layout Orientation
To specify horizontal-axis hugging for any stack view (whether it uses vertical or horizontal layout), use the
Interface Layout Orientation Horizontal
To specify vertical-axis hugging for any stack view (whether it uses vertical or horizontal layout), use the
Interface Layout Orientation Vertical
This method lets you specify a different hugging priority for each user interface axis. The default value for hugging priority, on both user interface axes, is
NSLayout. If you have not added constraints between the stack view and its enclosing view, the stack view stays as small as possible to fully contain its views—independent of the size of the view that contains it.
To configure a stack view to grow and shrink according to the size of its enclosing view, add constraints between the stack view and its enclosing view by using Auto Layout priorities higher than the hugging priority.
To configure a stack view to prevent its enclosing view from growing, use priorities for the constraints between the stack view and its enclosing view that are lower than the hugging priority.
The value of the hugging priority also affects spacing between views and between gravity areas, as described in the discussion for the