swiftUI 关于弹出警告框
在oc和swift中使用UIAlertController,集合 present函数,即可轻松实现弹框。
在swiftUI中。
import SwiftUI
struct ContentView: View {
@State private var showingAlert = false
@State private var showingAlert1 = false
var body: some View {
VStack{
Button("Show Alert") {
self.showingAlert = true
}
.alert(isPresented: $showingAlert) {
Alert(title: Text("Hello SwiftUI!"),
message: Text("This is some detail message"),
dismissButton: .default(Text("OK")))
}
}
}
}
网友评论