UIView.AddSubview(UIView) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
- Attributes
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:
- WillMoveToSuperview(UIView) :
- WillMoveToWindow(UIWindow) :
- WillRemoveSubview(UIView) :
- SubviewAdded(UIView) :
- MovedToSuperview() :
- MovedToWindow() :
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.