Instance Method

addView:inGravity:

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

Declaration

- (void)addView:(NSView *)view 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.

See Also

Adding and Removing Views

- insertView:atIndex:inGravity:

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

- setViews:inGravity:

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

- removeView:

Removes a specified view from the stack view.