Mac Developer Library

Developer

AppKit Framework Reference NSStackView Class Reference

Options
Deployment Target:

On This Page
Language:

NSStackView

A stack view employs Auto Layout (the system’s constraint-based layout feature) to arrange and align an array of views according to your specification. To use a stack view effectively, you need to understand the basics of Auto Layout constraints as described in Auto Layout Guide. More...

Inheritance


Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.9 and later.
  • Creates and returns a stack view with a specified array of views.

    Declaration

    Swift

    convenience init(views views: [AnyObject])

    Objective-C

    + (instancetype)stackViewWithViews:(NSArray *)views

    Parameters

    views

    The array of views for the new stack view.

    Return Value

    A stack view initialized with the specified array of views.

    Discussion

    The returned stack view has horizontal layout direction and its translatesAutoresizingMaskIntoConstraints property is set to the Boolean value NOfalse. The views you provide in the views parameter are placed into the stack view’s leading gravity area.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Specifies an array of views for a specified gravity area in the stack view, replacing any views previously assigned to the gravity area.

    Declaration

    Swift

    func setViews(_ views: [AnyObject], inGravity gravity: NSStackViewGravity)

    Objective-C

    - (void)setViews:(NSArray *)views inGravity:(NSStackViewGravity)gravity

    Parameters

    views

    The array of views you are specifying for the gravity area.

    gravity

    The gravity area that you’re specifying the array of views for. Valid values are those in the NSStackViewGravity enumeration, according to the stack view’s layout direction.

    Discussion

    Calling this method updates the stack view’s layout, which can change the stack view size. As a result, views could detach or clip according to the clipping resistance of the stack view and the visibility priorities of its views.

    A view in a detached state is not present in the stack view’s view hierarchy, but it still consumes memory. To respond to detachment and reattachment of views, implement an NSStackViewDelegate object and assign it to the delegate property.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • alignment alignment Property

    The view alignment within the stack view.

    Declaration

    Swift

    var alignment: NSLayoutAttribute

    Objective-C

    @property NSLayoutAttribute alignment

    Discussion

    The default value for this property depends on whether the stack view is horizontal or vertical:

    These constants are described as part of the NSLayoutAttribute enumeration in NSLayoutConstraint Class Reference; see that enumeration for the other possible alignment values.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • The horizontal or vertical layout direction of the stack view.

    Declaration

    Swift

    var orientation: NSUserInterfaceLayoutOrientation

    Objective-C

    @property NSUserInterfaceLayoutOrientation orientation

    Discussion

    Default value is NSUserInterfaceLayoutOrientationHorizontal. For values that apply to this property, see NSUserInterfaceLayoutOrientation.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • spacing spacing Property

    The minimum spacing, in points, between adjacent views in the stack view.

    Declaration

    Swift

    var spacing: CGFloat

    Objective-C

    @property CGFloat spacing

    Discussion

    A stack view uses this property to define the minimum distance between views within a gravity area and between neighboring views in adjacent gravity areas. The default value for the spacing property is 8.0 points.

    The automatically applied Auto Layout constraints for spacing are shown in Table 1.

    Table 1Default Auto Layout constraints for view spacing

    Constraint

    Value for constraint priority

    inter-view spacing == the spacing property value

    max (NSLayoutPriorityDefaultHigh, hugging priority)

    inter-gravity-area spacing == the spacing property value

    hugging priority

    inter-view spacing the spacing property value

    NSLayoutPriorityRequired

    The first row in Table 1 indicates that inter-view spacing is constrained to equal the value of the spacing property with a priority of at least NSLayoutPriorityDefaultHigh; you can increase this by setting a higher stack view hugging priority with the setHuggingPriority:forOrientation: method.

    The second row in Table 1 indicates that the spacing between adjacent views in neighboring gravity areas is constrained to equal the value of the spacing property with the priority of the stack view’s hugging priority.

    The third row in Table 1 indicates that inter-view spacing is allowed to grow larger than the value of the spacing property with a priority of NSLayoutPriorityRequired.

    In combination, these constraints result in the following typical stack view behavior: In a stack view whose hasEqualSpacing property is set to NOfalse (the default) and whose hugging priority is left at NSLayoutPriorityDefaultLow (the default), views within a gravity area remain a fixed distance from each other (equal to the value of the spacing property), and the distance between gravity areas grows and shrinks as the stack view grows and shrinks along its layout direction axis. If you set the hasEqualSpacing property to YEStrue and use the default hugging priority, then the distance between all adjacent views, including adjacent views in neighboring gravity areas, grows and shrinks as the stack view grows and shrinks.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • The geometric padding inside the stack view, surrounding its views, in points.

    Declaration

    Swift

    var edgeInsets: NSEdgeInsets

    Objective-C

    @property NSEdgeInsets edgeInsets

    Discussion

    The default value is (0, 0, 0, 0). Edge insets remain as they are if you change the value of a stack view’s orientation property or the value of its inherited userInterfaceLayoutDirection property.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • A Boolean value that indicates whether the spacing between adjacent views should equal each other.

    Declaration

    Swift

    var hasEqualSpacing: Bool

    Objective-C

    @property BOOL hasEqualSpacing

    Discussion

    The distances between adjacent views in a stack view are either constrained to equal each other or settable to custom spacings using the setCustomSpacing:afterView: method. The default value for the hasEqualSpacing property is NOfalse, which enables custom spacing. To require equal spacing, set this property to YEStrue, which disables the setCustomSpacing:afterView: method.

    With hasEqualSpacing set to NOfalse (the default), the Auto Layout constraints for spacing between views in a gravity area are as shown in table Table 1, in the description of the spacing property.

    If you specify equal spacing, the system changes these constraints to the values shown in table Table 2.

    Table 2Inter-view spacing constraints when equal spacing is enabled

    Constraint

    Value for constraint priority

    inter-view spacing == the spacing property

    hugging priority

    inter-view spacing the spacing property

    NSLayoutPriorityRequired

    Equal inter-view spacing

    NSLayoutPriorityDefaultLow

    Stack view hugging priority, identified as the constraint value in row 1, has the default valueNSLayoutPriorityDefaultLow. You can adjust hugging priority by using the setHuggingPriority:forOrientation: method.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • delegate delegate Property

    The delegate object for the stack view.

    Declaration

    Swift

    unowned(unsafe) var delegate: NSStackViewDelegate?

    Objective-C

    @property(assign) id< NSStackViewDelegate > delegate

    Discussion

    The system calls a delegate method when resizing has caused a view to be detached from or reattached to the stack view. For more information, see NSStackViewDelegate Protocol Reference.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Sets the Auto Layout priority for resisting clipping of views in the stack view when Auto Layout attempts to reduce the stack view’s size.

    Declaration

    Swift

    func setClippingResistancePriority(_ clippingResistancePriority: NSLayoutPriority, forOrientation orientation: NSLayoutConstraintOrientation)

    Objective-C

    - (void)setClippingResistancePriority:(NSLayoutPriority)clippingResistancePriority forOrientation:(NSLayoutConstraintOrientation)orientation

    Parameters

    clippingResistancePriority

    The clipping resistance Auto Layout priority you want to apply to the stack view for a given user interface axis. The default value is NSLayoutPriorityRequired, which disallows clipping. Other valid values are those in the NSLayoutPriority enumeration.

    orientation

    The horizontal or vertical user interface axis that the clipping resistance priority applies to; one of the constants from the NSUserInterfaceLayoutOrientation enumeration.

    Discussion

    A clipped view is one that is partially hidden beyond the border of its enclosing stack view. When Auto Layout attempts to reduce the stack view’s size (such as when a user attempts to reduce the size of the enclosing window), causing a view to no longer fit, the stack view clips or detaches the view, or else prevents further reduction of the stack view’s size.

    To allow view clipping, set a clipping resistance lower than the default value of NSLayoutPriorityRequired and set the visibility priority of all the stack view’s views to NSStackViewVisibilityPriorityMustHold.

    To ensure that views detach rather than clip, lower the clipping resistance for the stack view to a value less than the default of NSLayoutPriorityRequired and set the visibility priority for at least one view to a value less than NSStackViewVisibilityPriorityMustHold.

    If you disallow view clipping and disallow view detachment, which is the default behavior for a stack view, Auto Layout prevents the stack view from being reduced in size beyond the minimum needed to show all of its views.

    Clipping begins from the right and bottom sides of a stack view.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Sets the Auto Layout priority for the stack view to minimize its size, for a specified user interface axis.

    Declaration

    Swift

    func setHuggingPriority(_ huggingPriority: NSLayoutPriority, forOrientation orientation: NSLayoutConstraintOrientation)

    Objective-C

    - (void)setHuggingPriority:(NSLayoutPriority)huggingPriority forOrientation:(NSLayoutConstraintOrientation)orientation

    Parameters

    huggingPriority

    The Auto Layout priority for the stack view to minimize its size. The default value is NSLayoutPriorityDefaultLow. Other valid values are those in the NSLayoutPriority enumeration.

    orientation

    The horizontal or vertical user interface axis for which you’re setting the stack view’s hugging priority; one of the constants from the NSUserInterfaceLayoutOrientation enumeration.

    Discussion

    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 NSLayoutPriorityDefaultLow. 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 spacing property.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Adds a view to a stack view gravity area, at the end of the gravity area.

    Declaration

    Swift

    func addView(_ aView: NSView, inGravity gravity: NSStackViewGravity)

    Objective-C

    - (void)addView:(NSView *)aView inGravity:(NSStackViewGravity)gravity

    Parameters

    aView

    The view to add to the specified gravity area.

    gravity

    The gravity area that you are adding the specified view to. Valid values are those in the NSStackViewGravity enumeration.

    Discussion

    The location of a newly added view depends on the stack view layout direction and, for a horizontal stack view, on user interface language:

    • Horizontal: A newly added view appears at the trailing edge of the specified gravity area, as determined by the value of the inherited userInterfaceLayoutDirection property of the stack view. For a left to right language, a new view appears at the right side of the gravity area.

    • Vertical: A newly added view appears at the bottom of the specified gravity area.

    Calling this method updates the stack view’s layout, which can change the stack view size. As a result, views could detach or clip according to the clipping resistance of the stack view and the visibility priorities of its views.

    A view in a detached state is not present in the stack view’s view hierarchy, but it still consumes memory. To respond to detachment and reattachment of views, implement an NSStackViewDelegate object and assign it to the delegate property.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Adds a view to a stack view gravity area at a specified index position.

    Declaration

    Swift

    func insertView(_ aView: NSView, atIndex index: Int, inGravity gravity: NSStackViewGravity)

    Objective-C

    - (void)insertView:(NSView *)aView atIndex:(NSUInteger)index inGravity:(NSStackViewGravity)gravity

    Parameters

    aView

    The view to add to the specified gravity area.

    index

    The index position, within the gravity area, for the new view. The position of index 0 depends on the stack view layout direction and, for a horizontal stack view, on the user interface layout direction:

    • Horizontal: The 0 index for a gravity area is at the leading side, as determined by the value of the inherited userInterfaceLayoutDirection property of the stack view. For a left to right language, index 0 is at the left of the gravity area.

    • Vertical: The 0 index for a gravity area is at the top.

    See the userInterfaceLayoutDirection property and the setUserInterfaceLayoutDirection: method.

    gravity

    The gravity area that you are adding the specified view to. Valid values are those in the NSStackViewGravity enumeration.

    Discussion

    Calling this method updates the stack view’s layout, which can change the stack view size. As a result, views could detach or clip according to the clipping resistance of the stack view and the visibility priorities of its views.

    A view in a detached state is not present in the stack view’s view hierarchy, but it still consumes memory. To respond to detachment and reattachment of views, implement an NSStackViewDelegate object and assign it to the delegate property.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Removes a specified view from the stack view.

    Declaration

    Swift

    func removeView(_ aView: NSView)

    Objective-C

    - (void)removeView:(NSView *)aView

    Parameters

    aView

    The view you want to remove from the stack view.

    Discussion

    This method removes a view from a stack view whether the view is attached or detached. For an attached view only, you can alternatively call the removeFromSuperview method on the view.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns the custom spacing, in points, between a specified view in the stack view and the view that follows it.

    Declaration

    Swift

    func customSpacingAfterView(_ aView: NSView) -> CGFloat

    Objective-C

    - (CGFloat)customSpacingAfterView:(NSView *)aView

    Parameters

    aView

    The view whose trailing spacing you are getting.

    Return Value

    The number of points between the trailing edge of the specified view and the one that follows it (that is, the one with the next highest index order).

    Discussion

    If you set custom spacing for a view using the setCustomSpacing:afterView: method, it overrides the stack view’s default spacing as set in the spacing property.

    A stack view retains custom spacing across layout updates. Custom spacing for a view is lost if you remove the view from the stack view or specify a new value.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Specifies custom spacing, in points, to employ between a specified view and the view that follows it in the stack view.

    Declaration

    Swift

    func setCustomSpacing(_ spacing: CGFloat, afterView aView: NSView)

    Objective-C

    - (void)setCustomSpacing:(CGFloat)spacing afterView:(NSView *)aView

    Parameters

    spacing

    The custom trailing space to use between the aView view and the one that follows it, in points.

    Default value is NSStackViewSpacingUseDefault, which indicates that the view does not use custom spacing.

    aView

    The view whose trailing spacing you are setting.

    Discussion

    For a horizontal stack view, this method sets custom spacing between a specified view and the view to its right when the user interface direction is left to right. (See the inherited userInterfaceLayoutDirection property for information on layout direction.) For a vertical stack view, this method sets custom spacing below a specified view.

    If you set custom spacing for a view, it overrides the stack view’s default spacing for that view, as set in the spacing property.

    A stack view retains custom spacing across layout updates. Custom spacing for a view is lost if you remove the view from the stack view or specify a new value.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns the visibility priority for a specified view in the stack view.

    Declaration

    Swift

    func visibilityPriorityForView(_ aView: NSView) -> NSStackViewVisibilityPriority

    Objective-C

    - (NSStackViewVisibilityPriority)visibilityPriorityForView:(NSView *)aView

    Parameters

    aView

    The view that you are getting the visibility priority for.

    Return Value

    The visibility priority for the specified view.

    Discussion

    Visibility priority is the Auto Layout priority for a view to remain attached to a stack view when Auto Layout reduces the stack view’s size (such as when a user reduces the enclosing window’s size).

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Sets the Auto Layout priority for a view to remain attached to the stack view when Auto Layout reduces the stack view’s size.

    Declaration

    Swift

    func setVisibilityPriority(_ priority: NSStackViewVisibilityPriority, forView aView: NSView)

    Objective-C

    - (void)setVisibilityPriority:(NSStackViewVisibilityPriority)priority forView:(NSView *)aView

    Parameters

    priority

    The visibility priority for a specified view. Valid values are those in the NSStackViewVisibilityPriority enumeration.

    aView

    The view whose visibility priority you are setting.

    Discussion

    When Auto Layout reduces the stack view’s size (such as when a user reduces the size of the window containing the stack view), causing one or more views to no longer fit, the stack view detaches views in order of increasing visibility priority. A view with lower visibility priority detaches before a view with higher visibility priority. A set of views with identical, detachable visibility priority are all detached or reattached together. A view with the highest possible visibility priority never detaches.

    A view in a detached state is not present in the stack view’s view hierarchy, but it still consumes memory.

    The default visibility priority for a view is NSStackViewVisibilityPriorityMustHold, resulting in the view never detaching.

    To allow a view to detach as needed by the stack view, set a visibility priority of NSStackViewVisibilityPriorityDetachOnlyIfNecessary. To force a view to detach regardless of the enclosing view’s size, set a visibility priority of NSStackViewVisibilityPriorityNotVisible. To explicitly reattach a view to a stack view, set a visibility priority of NSStackViewVisibilityPriorityMustHold.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • views views Property

    The array of views owned by the stack view. (read-only)

    Declaration

    Swift

    var views: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *views

    Discussion

    The views array always contains all of the views owned and managed by the stack view, regardless of their gravity area placement and regardless of whether or not they are attached. The index position of each view in the array matches the view ordering within the stack view. A detached view’s index position is its stack view position when attached.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns the array of views in the specified gravity area in the stack view.

    Declaration

    Swift

    func viewsInGravity(_ gravity: NSStackViewGravity) -> [AnyObject]

    Objective-C

    - (NSArray *)viewsInGravity:(NSStackViewGravity)gravity

    Parameters

    gravity

    The gravity area whose view array you want to get. Valid values are those in the NSStackViewGravity enumeration, according to the stack view’s layout direction..

    Return Value

    The array of views in a specified gravity area.

    Discussion

    The returned array contains all of the views in the specified gravity area of the stack view, regardless of whether they are attached. The index position of each view in the array matches the view ordering within the gravity area. A detached view’s index position is its gravity area position when attached.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • An array containing the detached views from all of the stack view’s gravity areas. (read-only)

    Declaration

    Swift

    var detachedViews: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *detachedViews

    Discussion

    A view in a detached state is not present in the stack view’s view hierarchy, but it still consumes memory.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns the Auto Layout priority for resisting clipping of views in the stack view when Auto Layout attempts to reduce the stack view’s size.

    Declaration

    Swift

    func clippingResistancePriorityForOrientation(_ orientation: NSLayoutConstraintOrientation) -> NSLayoutPriority

    Objective-C

    - (NSLayoutPriority)clippingResistancePriorityForOrientation:(NSLayoutConstraintOrientation)orientation

    Parameters

    orientation

    The stack view layout direction to which the clipping resistance priority applies.

    Return Value

    A layout constraint priority that identifies the clipping resistance for the stack view.

    Discussion

    For an explanation of clipping resistance and how to use it for a stack view, see the setClippingResistancePriority:forOrientation: method.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns the Auto Layout priority for the stack view to minimize its size to fit its contained views as closely as possible, for a specified user interface axis.

    Declaration

    Swift

    func huggingPriorityForOrientation(_ orientation: NSLayoutConstraintOrientation) -> NSLayoutPriority

    Objective-C

    - (NSLayoutPriority)huggingPriorityForOrientation:(NSLayoutConstraintOrientation)orientation

    Parameters

    orientation

    The user interface axis (horizontal or vertical) whose hugging priority you want to get from the stack view. Valid values are those in the NSUserInterfaceLayoutOrientation enumeration.

    Return Value

    The Auto Layout priority for the stack view to minimize its size.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • The two stack view layout directions and, for clipping resistance and hugging priority, the two user interface axes.

    Declaration

    Swift

    enum NSUserInterfaceLayoutOrientation : Int { case Horizontal case Vertical }

    Objective-C

    typedef enum : NSInteger { NSUserInterfaceLayoutOrientationHorizontal = 0, NSUserInterfaceLayoutOrientationVertical = 1 } NSUserInterfaceLayoutOrientation;

    Constants

    • Horizontal

      NSUserInterfaceLayoutOrientationHorizontal

      For the orientation property, horizontal layout for the stack view. For clipping resistance and hugging priority, the horizontal user interface axis.

      The leading, center, and trailing gravity areas in a horizontal stack view are arranged left to right or right to left depending on the value of the inherited userInterfaceLayoutDirection property.

      Available in OS X v10.9 and later.

    • Vertical

      NSUserInterfaceLayoutOrientationVertical

      For the orientation property, vertical layout for the stack view. For clipping resistance and hugging priority, the vertical user interface axis.

      The leading, center, and trailing gravity areas in a vertical stack view are arranged top to bottom.

      Available in OS X v10.9 and later.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • The various gravity areas available in a stack view.

    Declaration

    Swift

    enum NSStackViewGravity : Int { case Top case Center case Bottom }

    Objective-C

    typedef enum : NSInteger { NSStackViewGravityTop = 1, NSStackViewGravityLeading = 1, NSStackViewGravityCenter = 2, NSStackViewGravityBottom = 3, NSStackViewGravityTrailing = 3 } NSStackViewGravity;

    Constants

    • Top

      NSStackViewGravityTop

      The topmost gravity area in a vertically oriented stack view.

      Use only when the value of the orientation property is NSUserInterfaceLayoutOrientationVertical.

      Available in OS X v10.9 and later.

    • NSStackViewGravityLeading

      NSStackViewGravityLeading

      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.

      For a left to right layout direction, the leading gravity area is on the left. Use only when the value of the orientation property is NSUserInterfaceLayoutOrientationHorizontal.

      Available in OS X v10.9 and later.

    • Center

      NSStackViewGravityCenter

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

      Available in OS X v10.9 and later.

    • Bottom

      NSStackViewGravityBottom

      The bottommost gravity area in a vertically oriented stack view.

      Use only when the value of the orientation property is NSUserInterfaceLayoutOrientationVertical.

      Available in OS X v10.9 and later.

    • NSStackViewGravityTrailing

      NSStackViewGravityTrailing

      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.

      For a left to right layout direction, the trailing gravity area is on the right. Use only when the value of the orientation property is NSUserInterfaceLayoutOrientationHorizontal.

      Available in OS X v10.9 and later.

    Discussion

    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:atIndex:inGravity: and setViews:inGravity: methods.

    In a horizontally oriented stack view, the three gravity areas are NSStackViewGravityLeading, NSStackViewGravityCenter, and NSStackViewGravityTrailing. 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 setUserInterfaceLayoutDirection: method. For a userInterfaceLayoutDirection property value of NSUserInterfaceLayoutDirectionLeftToRight, the leading gravity area is on the left.

    In a vertically oriented stack view, the three gravity areas are always NSStackViewGravityTop, NSStackViewGravityCenter, and NSStackViewGravityBottom.

    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.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • The various Auto Layout priorities for a view in the stack view to remain attached.

    Declaration

    Swift

    typealias NSStackViewVisibilityPriority = Float

    Objective-C

    enum { NSStackViewVisibilityPriorityMustHold = 1000, NSStackViewVisibilityPriorityDetachOnlyIfNecessary = 900, NSStackViewVisibilityPriorityNotVisible = 0 }; typedef float NSStackViewVisibilityPriority;

    Constants

    • NSStackViewVisibilityPriorityMustHold

      NSStackViewVisibilityPriorityMustHold

      The default value, and maximum Auto Layout priority, which results in a view never detaching from the stack view.

      Available in OS X v10.9 through OS X v10.9.

    • NSStackViewVisibilityPriorityDetachOnlyIfNecessary

      NSStackViewVisibilityPriorityDetachOnlyIfNecessary

      The Auto Layout priority that results in detachment of a view when there is insufficient space in the stack view to display it fully.

      Available in OS X v10.9 through OS X v10.9.

    • NSStackViewVisibilityPriorityNotVisible

      NSStackViewVisibilityPriorityNotVisible

      The minimum Auto Layout priority, which forces a view to detach from the stack view.

      Available in OS X v10.9 through OS X v10.9.

    Discussion

    For an explanation of how visibility priority interacts with clipping resistance to determine the detachment behavior of a stack view’s views, see the discussions for the setClippingResistancePriority:forOrientation: and setVisibilityPriority:forView: methods.

    A view in a detached state is not present in the stack view’s view hierarchy, but it still consumes memory.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • The flag to specify default spacing following each view in the stack view.

    Declaration

    Objective-C

    #define NSStackViewSpacingUseDefault (FLT_MAX)

    Constants

    • NSStackViewSpacingUseDefault

      NSStackViewSpacingUseDefault

      The flag to specify default spacing following each view in the stack view.

      Available in OS X v10.9 through OS X v10.9.

    Discussion

    To specify custom spacing, use the setCustomSpacing:afterView: method with the spacing you want, in points. To explicitly specify default spacing, call that method with this flag.

    Import Statement