Answers for "swiftui alert dismiss action"

1

how to add button to alert swiftui

@State var showAlert = false

var body: some View {
  Button(action: {
    self.showAlert = true
  }) {
    Text("Show Alert")
  }
  .presentation($showAlert) {
      Alert(title: Text("Title"), message: Text("Message..."),
          primaryButton: .default (Text("OK")) {
            print("OK button tapped")
          },
          secondaryButton: .cancel()
      )
  }
}
Posted by: Guest on March-17-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language