dialogIcon(_:)
Configures the icon used by alerts.
Declaration
nonisolated func dialogIcon(_ icon: Image?) -> some Scene
Parameters
- icon:
The custom icon to use for the alert. Passing
nilwill use the default app icon.
Discussion
In macOS, this icon replaces the default icon of the app.
struct MyApp: App {
@State private var isShowingDialog = false
var body: some Scene {
Window(...) {
Button("Delete items") {
isShowingDialog = true
}
}
AlertScene(
"Are you sure you want to erase these items?",
isPresented: $isShowingDialog
) {
Button("Erase", role: .destructive) {
// Handle item deletion.
}
Button("Cancel", role: .cancel) {
// Handle cancellation
}
}
.dialogIcon(Image(Trash.png))
}
}