【发布时间】:2021-01-10 12:34:26
【问题描述】:
我正在编写一个菜单栏应用程序,其中只有一个弹出框,即操作所在的位置。目标是 MacOS 10.15 Catalina。
在弹出窗口中,我想显示一个警报。代码是这样的:
struct ContentView: View {
@State private var confirm = false
var body: some View {
return VStack {
Button("Reset Settings", action: {
self.confirm = true
})
.alert(isPresented: $confirm) {
Alert(
title: Text("Do you really want to?"),
message: Text("Do you want to talk about it?"),
primaryButton: .default(Text("Oh, yeah")) {
print("Well, if you insist …")
},
secondaryButton: .cancel()
)
}
}
}
}
警报运行良好,但它出现在 弹出框之后。
如何将警报放在弹出框前面?
【问题讨论】:
标签: swift macos swiftui alert popover