<!--
{
  "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/viewWillAppear(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI19UIHostingControllerC14viewWillAppearyySbF"
  },
  "title" : "viewWillAppear(_:)"
}
-->

# viewWillAppear(_:)

Notifies the view controller that its view is about to be added to a
view hierarchy.

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

## Parameters

`animated`

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

## Discussion

SwiftUI calls this method before adding the hosting controller’s root
view to the view hierarchy. You can override this method to perform
custom tasks associated with the appearance 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)