Sets the Auto Layout priority for a view to remain attached to the stack view when Auto Layout reduces the stack view’s size.
SDK
- macOS 10.9+
Framework
- App
Kit
Declaration
- (void)setVisibilityPriority:(NSStack View Visibility Priority)priority forView:(NSView *)view;
Parameters
priority
The visibility priority for a specified view. Valid values are those in the
NSStack
enumeration.View Visibility Priority aView
The view whose visibility priority you are setting.
Important
If you attempt to set visibility priority for a view that is not in the stack view, the system raises an exception.
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 NSStack
, resulting in the view never detaching.
To allow a view to detach as needed by the stack view, set a visibility priority of NSStack
. To force a view to detach regardless of the enclosing view’s size, set a visibility priority of NSStack
. To explicitly reattach a view to a stack view, set a visibility priority of NSStack
.