presentationBackground

Sets the presentation background of the enclosing sheet using a shape style.

View ModifieriOS 16.4+macOS 13.3+tvOS 16.4+watchOS 9.4+

Overloads

2 ways to call compose().presentationBackground(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().presentationBackground(style: SwiftUI.ShapeStyle)
Swift
nonisolated func presentationBackground<S>(
    _ style: S
) -> some View
where S : ShapeStyle

Parameters

Discussion

The following example uses the Material.thick material as the sheet background:

struct ContentView: View {
    @State private var showSettings = false

    var body: some View {
        Button("View Settings") {
            showSettings = true
        }
        .sheet(isPresented: $showSettings) {
            SettingsView()
                .presentationBackground(.thickMaterial)
        }
    }
}

The presentationBackground(_:) modifier differs from the View.background(_:ignoresSafeAreaEdges:) modifier in several key ways. A presentation background:

  • Automatically fills the entire presentation.
  • Allows views behind the presentation to show through translucent styles on supported platforms.

or transparency — the background is always opaque.

See also

More in Presentation.