addSubview(_:positioned:relativeTo:)
Inserts a view among the view’s subviews so it’s displayed immediately above or below another view.
Declaration
func addSubview(_ view: NSView, positioned place: NSWindow.OrderingMode, relativeTo otherView: NSView?)Parameters
- view:
The view object to add to the view as a subview.
- place:
An
enumconstant specifying the position of theaViewrelative tootherView. Valid values areNSWindowAboveorNSWindowBelow. - otherView:
The other view
aViewis to be positioned relative to. IfotherViewisnil(or isn’t a subview of the view),aViewis added above or below all of its new siblings.
Discussion
This method also sets the view as the next responder of aView.
The view retains aView. If you use removeFromSuperview() to remove aView from the view hierarchy, aView is released. If you want to keep using aView after removing it from the view hierarchy (if, for example, you are swapping through a number of views), you must retain it before invoking removeFromSuperview().