UIView.AddSubview(UIView) UIView.AddSubview(UIView) Method

Definition

Adds the specified view as a subview of this view.

[Foundation.Export("addSubview:")]
public virtual void AddSubview (UIKit.UIView view);
abstract member AddSubview : UIKit.UIView -> unit
override this.AddSubview : UIKit.UIView -> unit

Parameters

view
UIView UIView

The UIView to add as a nested view of this view.

Remarks

AddSubview(UIView) appends the view to the end of this UIView's Subviews. The methods InsertSubview(UIView, nint), InsertSubviewBelow(UIView, UIView), and InsertSubviewAbove(UIView, UIView) can be used to control the order.

To remove a UIView from Subviews, call RemoveFromSuperview() on the child UIView.

Since UIViews can only have direct ancestor, this will overwrite the existing Superview of the view.

A number of methods are called when a subview is added or removed:

The following diagram shows the sequence of calls resulting from a call to AddSubview(UIView). Note that the calls to WillMoveToWindow(UIWindow) and MovedToWindow() occur shortly after AddSubview(UIView) has completed.

Applies to

See also