dialogIcon(_:)
Configures the icon used by dialogs within this view.
Declaration
nonisolated func dialogIcon(_ icon: Image?) -> some View
Parameters
- icon:
The custom icon to use for confirmation dialogs and alerts. Passing
nilwill use the default app icon.
Discussion
On macOS, this icon replaces the default icon of the app.
On watchOS, this icon will be shown in any dialogs presented.
This modifier has no effect on other platforms.
The following example configures a confirmationDialog with a custom image.
Button("Delete items") {
isShowingDialog = true
}
.confirmationDialog(
"Are you sure you want to erase these items?",
isPresented: $isShowingDialog
) {
Button("Erase", role: .destructive) {
// Handle item deletion.
}
Button("Cancel", role: .cancel) {
isShowingDialog = false
}
}
.dialogIcon(Image(...))