<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AnyView",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7AnyViewV"
  },
  "title" : "AnyView"
}
-->

# AnyView

A type-erased view.

```
@frozen nonisolated struct AnyView
```

## Overview

An `AnyView` allows changing the type of view used in a given view
hierarchy. Whenever the type of view used with an `AnyView` changes, the old
hierarchy is destroyed and a new hierarchy is created for the new type.

## Topics

### Creating a view

[`init(_:)`](/documentation/SwiftUI/AnyView/init(_:))

Create an instance that type-erases `view`.

[`init(erasing:)`](/documentation/SwiftUI/AnyView/init(erasing:))



---

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)