<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/UIHostingController/viewWillDisappear(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI19UIHostingControllerC17viewWillDisappearyySbF"
  },
  "title" : "viewWillDisappear(_:)"
}
-->

# viewWillDisappear(_:)

Notifies the view controller that its view will be removed from a
view hierarchy.

```
@MainActor @preconcurrency override dynamic func viewWillDisappear(_ animated: Bool)
```

## Parameters

`animated`

If `true`, the view is being removed
using an animation.

## Discussion

SwiftUI calls this method before removing the hosting controller’s root
view from the view hierarchy. You can override this method to perform
custom tasks associated with the disappearance of the view. If you
override this method, you must call `super` at some point in your
implementation.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)