Instance Method


Exchanges the subviews at the specified indices.


func exchangeSubview(at index1: Int, withSubviewAt index2: Int)



The index of the first subview in the receiver.


The index of the second subview in the receiver.


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

Related Symbols

func insertSubview(UIView, belowSubview: UIView)

Inserts a view below another view in the view hierarchy.

func insertSubview(UIView, aboveSubview: UIView)

Inserts a view above another view in the view hierarchy.

func addSubview(UIView)

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

func insertSubview(UIView, at: Int)

Inserts a subview at the specified index.