Instance Method


Inserts a subview at the specified index.


func insertSubview(_ view: UIView, at index: Int)



The view to insert. This value cannot be nil.


The index in the array of the subviews property at which to insert the view. Subview indices start at 0 and cannot be greater than the number of subviews.


This method establishes a strong reference to view and sets its next responder to the receiver, which is its new superview.

Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

See Also

Related Symbols

func insertSubview(UIView, belowSubview: UIView)

Inserts a view below another view in the view hierarchy.

func exchangeSubview(at: Int, withSubviewAt: Int)

Exchanges the subviews at the specified indices.

func addSubview(UIView)

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

func insertSubview(UIView, aboveSubview: UIView)

Inserts a view above another view in the view hierarchy.