---
title: removeFromSuperview()
framework: uikit
role: symbol
role_heading: Instance Method
path: uikit/uiview/removefromsuperview()
---

# removeFromSuperview()

Unlinks the view from its superview and its window, and removes it from the responder chain.

## Declaration

```swift
func removeFromSuperview()
```

## Mentioned in

Creating a custom container view controller

## Discussion

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.

## See Also

### Managing the view hierarchy

- [superview](uikit/uiview/superview.md)
- [subviews](uikit/uiview/subviews.md)
- [window](uikit/uiview/window.md)
- [addSubview(_:)](uikit/uiview/addsubview(_:).md)
- [bringSubviewToFront(_:)](uikit/uiview/bringsubviewtofront(_:).md)
- [sendSubviewToBack(_:)](uikit/uiview/sendsubviewtoback(_:).md)
- [insertSubview(_:at:)](uikit/uiview/insertsubview(_:at:).md)
- [insertSubview(_:aboveSubview:)](uikit/uiview/insertsubview(_:abovesubview:).md)
- [insertSubview(_:belowSubview:)](uikit/uiview/insertsubview(_:belowsubview:).md)
- [exchangeSubview(at:withSubviewAt:)](uikit/uiview/exchangesubview(at:withsubviewat:).md)
- [isDescendant(of:)](uikit/uiview/isdescendant(of:).md)
