Instance Method

exchangeSubviewAtIndex:withSubviewAtIndex:

Exchanges the subviews at the specified indices.

Declaration

- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;

Parameters

index1

The index of the first subview in the receiver.

index2

The index of the second subview in the receiver.

Discussion

Each index represents the position of the corresponding view in the array in the subviews property. Subview indices start at 0 and cannot be greater than the number of subviews. This method does not change the superview of either view but simply swaps their positions in the subviews array.

See Also

Managing the View Hierarchy

superview

The receiver’s superview, or nil if it has none.

subviews

The receiver’s immediate subviews.

window

The receiver’s window object, or nil if it has none.

- addSubview:

Adds a view to the end of the receiver’s list of subviews.

- bringSubviewToFront:

Moves the specified subview so that it appears on top of its siblings.

- sendSubviewToBack:

Moves the specified subview so that it appears behind its siblings.

- removeFromSuperview

Unlinks the view from its superview and its window, and removes it from the responder chain.

- insertSubview:atIndex:

Inserts a subview at the specified index.

- insertSubview:aboveSubview:

Inserts a view above another view in the view hierarchy.

- insertSubview:belowSubview:

Inserts a view below another view in the view hierarchy.

- isDescendantOfView:

Returns a Boolean value indicating whether the receiver is a subview of a given view or identical to that view.