Alert warning prompt box SwiftUI of control (including demo)

Alert warning prompt box SwiftUI of control (including demo)

Code

import SwiftUI




struct ContentView: View {
    
    @State var showAlert = false
    
    var body: some View {
        NavigationView {
            VStack {
                Button("Show Alert"){
                    self.showAlert = true
                }.alert(isPresented: $showAlert){
                    Alert(title: Text("hello"), message: Text("This is our first Alert Message"), dismissButton: .default(Text("OK")))
                }
            }
            .navigationBarTitle(Text("基础控件"))
            
        }
        
    }
    
}

effect

41085-39cb7dbcde86e1d7.gif
Jietu20200119-001813.gif

More attention SwiftUI tutorials and code columns

Published 637 original articles · won praise 4 · views 50000 +

Guess you like

Origin blog.csdn.net/iCloudEnd/article/details/104037787