【发布时间】:2019-06-04 17:02:42
【问题描述】:
在SwiftUI 中,我发现了Alert 类型。但我想知道如何使用presentation 方法来展示它。
初始化Alert 非常简单。但是怎么使用绑定呢?
struct ContentView : View {
var body: some View {
Button(action: {
// Don't know how to use the `binding` below
presentation(binding, alert: {
Alert(title: Text("Hello"))
})
}, label: {
Text("asdf")
})
}
}
绑定的类型是Binding<Bool>
【问题讨论】: