presentationBackground(alignment:content:)
Sets the presentation background of the enclosing sheet to a custom view.
Declaration
nonisolated func presentationBackground<V>(alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View where V : View
Parameters
Discussion
The following example uses a yellow view 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 {
Color.yellow
}
}
}
}The presentationBackground(alignment:content:) modifier differs from the background(alignment:content:) modifier in several key ways. A presentation background:
Automatically fills the entire presentation.
Allows views behind the presentation to show through translucent areas of the
contenton supported platforms.