.spatialOverlay()

iOS 26+

Overlays SwiftUI views on 3D models using 3D alignment instead of 2D positioning, enabling AR and 3D experiences.

3D & AR
Official Apple Documentation →
iOS User Coverage
14.1%
coverage

14.1% of iOS users can use this modifier

Version Compatibility
iOS 26.1
10.7% Supported
iOS 26.2
2.0% Supported
iOS 26.0
1.3% Supported

iOS 26+ required

Variants
.spatialOverlay(alignment:content:)

Places an overlay at a 3D alignment point

Parameters:
  • alignment: Alignment3D
  • content: View
Code Examples

3D Model Overlay

Add a SwiftUI label overlaying a 3D model

Model3D(named: "teapot")
    .spatialOverlay(alignment: .top) {
        Text("Teapot")
            .padding()
            .background(.thinMaterial)
    }

Conditional Availability (iOS 26+)

Use #available to conditionally apply 3D overlays

if #available(iOS 26, *) {
    Model3D(named: "teapot")
        .spatialOverlay(alignment: .top) {
            Text("Teapot")
                .padding()
                .background(.thinMaterial)
        }
} else {
    // Fallback for iOS 18 and earlier
    Model3D(named: "teapot")
        .overlay(alignment: .top) {
            Text("Teapot")
                .padding()
                .background(.thinMaterial)
        }
}

Loading related modifiers...

Using with Older iOS Versions

If your app supports iOS versions older than 26, you can use #available to conditionally apply this modifier:

if #available(iOS 26, *) {
    myView.spatialOverlay()
} else {
    // Fallback for older iOS versions
    myView
}

Check the code examples above for specific #available patterns with this modifier.

Frequently Asked Questions

What iOS version is required for .spatialOverlay()?

The .spatialOverlay() modifier requires iOS 26 or later. This means 14.1% of current iOS users can use this modifier.

Can I use this if my app supports older iOS versions?

Yes! Use #available(iOS 26, *) to conditionally apply this modifier only on devices running iOS 26 or later, with a fallback for older versions.

How do I use .spatialOverlay() in SwiftUI?

Apply the .spatialOverlay() modifier to any SwiftUI view. Check the code examples above for usage patterns.

Where can I learn more?

Visit the official Apple documentation for detailed information.

Explore More SwiftUI Modifiers