【发布时间】:2020-05-08 17:59:20
【问题描述】:
基本上,在我的 ContentView 中,当 Binding variableName(不是 ContentView 中的 variableName,来自 MapView 类的 variableName)为真时,我试图创建一个 CreateItemButton()。所以.... ContentView 的伪代码类似于:
struct ContentView: View {
@State private var variableName: Bool = false
var body: some View {
VStack {
ZStack {
MapView(variableName: $variableName)
//Display the CreateEventButton() view here if $variableName is true.
}
}
}
}
我希望有一些函数可以在 MapView() 视图上调用以选择性地显示 CreateEventButton() 视图,但我发现最接近我需要的是 .sheet(isPresented: $variableName) 函数....而且我需要将视图直接显示在地图顶部,而不是拉出带有视图的新工作表。让我知道是否可以添加任何内容以帮助使其更清晰!
【问题讨论】:
标签: view binding swiftui mapbox