How it works
VolumeViewpointUpdateStrategy tells SwiftUI how a volumetric window should respond as a viewer changes their position relative to it. A volume can be observed from many angles in a shared space, and this type lets you declare whether its content should keep re-orienting to face the current viewpoint or settle on a single fixed perspective. Reach for it when you want explicit control over how — and how aggressively — a volume tracks the people looking at it, rather than accepting the system default.
Choose a strategy value
VolumeViewpointUpdateStrategyis a struct exposing predefined strategies as static members. The example selects.surrounding, which keeps the volume's content updating so it continues to read correctly as the viewer moves around it. You pick the member whose tracking behavior matches your scene.Hold the strategy in state
Because the strategy is an ordinary value, you can store and swap it like any other piece of view state. Here it lives in
@State private var strategy: VolumeViewpointUpdateStrategy = .surrounding, so the chosen behavior is a single source of truth the view can react to and you could later change at runtime.Apply it with volumeViewpointUpdateStrategy(_:)
The
volumeViewpointUpdateStrategy(_:)view modifier is where the symbol plugs into the hierarchy — it attaches your chosen strategy to the content it wraps. In the example.volumeViewpointUpdateStrategy(strategy)is applied to the volume's card, binding the stored value to the actual update behavior the system uses.Scope the modifier to the volume's content
The strategy governs the view subtree it modifies, so placement matters. The example applies it after laying out and framing the
VStackcontent (theLabelandTextrows) inside its.frame(width: 320, height: 220)and material background, marking that content as what should follow the viewer.
@State private var strategy: VolumeViewpointUpdateStrategy = .surrounding to a different available strategy and observe how the volume stops re-orienting to follow the viewer.Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct VolumeViewpointUpdateStrategyDemo: View {
@State private var strategy: VolumeViewpointUpdateStrategy = .surrounding
var body: some View {
VStack(spacing: 16) {
Label("Volumetric Window", systemImage: "cube.transparent")
.font(.title2.bold())
Text("Viewpoint update: surrounding")
.font(.callout)
.foregroundStyle(.secondary)
Text("The volume re-renders content to follow the viewer as they move around it.")
.multilineTextAlignment(.center)
.foregroundStyle(.secondary)
}
.frame(width: 320, height: 220)
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 24))
.volumeViewpointUpdateStrategy(strategy)
.padding()
}
}