【发布时间】:2022-01-03 21:52:57
【问题描述】:
我想点击一个按钮并在 SwiftUI 中为 macOS 应用程序显示上下文菜单。我可以看到按钮,但是当我点击按钮时没有任何反应。
let menuItems = ContextMenu {
Button("Today") {}
Button("Tomorrow") {}
}
Button {
// action
} label: {
Label("Add Date", systemImage: "calendar")
.contextMenu(menuItems)
}
有什么想法吗?
【问题讨论】: