fullScreenCover
Presents a modal view that covers as much of the screen as possible when binding to a Boolean value you provide is true.
View ModifieriOS 14.0+tvOS 14.0+watchOS 7.0+
Overloads
2 ways to call compose().fullScreenCover(). Each is one SwiftUI overload, picked by the arguments you pass.
compose().fullScreenCover({
isPresented: Binding<boolean>,
onDismiss?: (() => void) | null,
content: ReactNode,
})nonisolated func fullScreenCover<Content>(
isPresented: Binding<Bool>,
onDismiss: (() -> Void)? = nil,
@ContentBuilder content: @escaping () -> Content
) -> some View
where Content : ViewParameters
options.isPresented*Binding<boolean>A binding to a Boolean value that determines whether to present the sheet.
options.onDismiss(() => void) | nullThe closure to execute when dismissing the modal view.
options.content*ReactNodeA closure that returns the content of the modal view.
Discussion
Use this method to show a modal view that covers as much of the screen
as possible. The example below displays a custom view when the user
toggles the value of the isPresenting binding:
struct FullScreenCoverPresentedOnDismiss: View {
@State private var isPresenting = false
var body: some View {
Button("Present Full-Screen Cover") {
isPresenting.toggle()
}
.fullScreenCover(isPresented: $isPresenting,
onDismiss: didDismiss) {
VStack {
Text("A full-screen modal view.")
.font(.title)
Text("Tap to Dismiss")
}
.onTapGesture {
isPresenting.toggle()
}
.foregroundColor(.white)
.frame(maxWidth: .infinity,
maxHeight: .infinity)
.background(Color.blue)
.ignoresSafeArea(edges: .all)
}
}
func didDismiss() {
// Handle the dismissing action.
}
}See also
More in Presentation.
- alertPresents an alert when a given condition is true, using a localized string resource for the title.
- confirmationDialogPresents a confirmation dialog when a given condition is true, using a localized string resource for the title.
- contextMenuAdds an item-based context menu to a view.
- dialogIconConfigures the icon used by dialogs within this view.
- dialogSuppressionToggleEnables user suppression of dialogs and alerts presented within self, with a custom suppression message on macOS. Unused on other platforms.
- dismissalConfirmationDialogPresents a confirmation dialog upon an attempt to dismiss the window for this view.
- documentBrowserContextMenuAdds to a DocumentLaunchView actions that accept a list of selected files as their parameter.
- fileDialogBrowserOptionsOn macOS, configures the fileExporter, fileImporter, or fileMover to provide a refined URL search experience: include or exclude hidden files, allow searching by tag, etc.
- fileDialogConfirmationLabelOn macOS, configures the fileExporter, fileImporter, or fileMover with a custom confirmation button label.
- fileDialogCustomizationIDOn macOS, configures the fileExporter, fileImporter, or fileMover to persist and restore the file dialog configuration.
- fileDialogDefaultDirectoryConfigures the fileExporter, fileImporter, or fileMover to open with the specified default directory.
- fileDialogImportsUnresolvedAliasesOn macOS, configures the fileExporter, fileImporter, or fileMover behavior when a user chooses an alias.