show alert swiftui
struct ContentView: View { @State var showsAlert = false var body: some View { Button(action: { self.showsAlert.toggle() }) { Text("Show Alert") } .alert(isPresented: self.$showsAlert) { Alert(title: Text("Hello")) } } }
show alert swiftui
struct ContentView: View { @State var showsAlert = false var body: some View { Button(action: { self.showsAlert.toggle() }) { Text("Show Alert") } .alert(isPresented: self.$showsAlert) { Alert(title: Text("Hello")) } } }
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() ) } }
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us