Contents

replaceSubview(_:with:)

Replaces one of the view’s subviews with another view.

Declaration

func replaceSubview(_ oldView: NSView, with newView: NSView)

Parameters

  • oldView:

    The view to be replaced by newView. May not be nil.

  • newView:

    The view to replace oldView. May not be nil.

Discussion

This method does nothing if oldView is not a subview of the view.

Neither oldView nor newView may be nil, and the behavior is undefined if either of these parameters is nil.

This method causes oldView to be released; if you plan to reuse it, be sure to retain it before sending this message and to release it as appropriate when adding it as a subview of another NSView.

Calling this method also removes any constraints associated with oldView and its subtree.

See Also

Adding and Removing Subviews