Last active
June 21, 2020 07:26
-
-
Save gahntpo/1ae38f12b1e2c46f31e13b33b36e1c8b to your computer and use it in GitHub Desktop.
using alerts in swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct AlertExampleView: View { | |
@State var showAlert: Bool = false | |
var body: some View { | |
VStack { | |
Text("This is an example").font(.headline) | |
Button(action: { | |
self.showAlert = true | |
}) { | |
Text("show alert sheet") | |
} | |
.alert(isPresented: $showAlert, content: { | |
Alert(title: Text("alert"), | |
message: Text("details of alert"), | |
dismissButton: Alert.Button.destructive(Text("destructive"), | |
action: { print("pressed destruction in alert") } | |
) | |
) | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment