<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Scene/immersiveEnvironmentBehavior(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5ScenePAAE28immersiveEnvironmentBehavioryQrAA09ImmersiveeF0VF"
  },
  "title" : "immersiveEnvironmentBehavior(_:)"
}
-->

# immersiveEnvironmentBehavior(_:)

Sets the immersive environment behavior that should apply when this
scene opens.

```
nonisolated func immersiveEnvironmentBehavior(_ behavior: ImmersiveEnvironmentBehavior) -> some Scene
```

## Parameters

`behavior`

A immersive environment behavior that should be applied by
the system when this scene opens.

## Return Value

A scene that uses the specified `behavior`.

## Discussion

Use this modifier to control how the immersive environment behaves when
an [`ImmersiveSpace`](/documentation/SwiftUI/ImmersiveSpace) is opened, that uses an immersion style that
supports keeping the immersive environment visible.

For example, the following app defines an Immersive Space that displays
an interactive car engine model, and by setting the system environment
behavior to `.coexist`, the immersive environment can remain shown
while inspecting the details of the engine:

```
@main
struct App: App {
    var body: some Scene {
        ImmersiveSpace {
            CarEngineModel()
        }
        .immersiveEnvironmentBehavior(.coexist)
    }
}
```

Note: The behavior is a preference and does not always have to be
honored by the system.

---

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)