Answers for "swiftui show alert dialog on toggle button"

5

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"))
        }
    }
}
Posted by: Guest on March-13-2020

Code answers related to "swiftui show alert dialog on toggle button"

Code answers related to "Swift"

Browse Popular Code Answers by Language