SwiftUI 控件之Alert 告警提示框(含demo)
代码
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("基础控件"))
}
}
}
效果
更多SwiftUI教程和代码关注专栏
- 请关注我的专栏 SwiftUI教程与源码