Unlinks the view from its superview and its window, and removes it from the responder chain.
SDKs
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
func removeFromSuperview()
Discussion
If the view’s superview is not nil
, the superview releases the view.
Calling this method removes any constraints that refer to the view you are removing, or that refer to any view in the subtree of the view you are removing.
Important
Never call this method from inside your view’s draw(_:)
method.