Skip to content

Instantly share code, notes, and snippets.

@gahntpo
Last active June 21, 2020 07:26
Show Gist options
  • Save gahntpo/1ae38f12b1e2c46f31e13b33b36e1c8b to your computer and use it in GitHub Desktop.
Save gahntpo/1ae38f12b1e2c46f31e13b33b36e1c8b to your computer and use it in GitHub Desktop.
using alerts in swift
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