我的视图上有一个齿轮按钮,当用户单击它时我想显示按钮菜单。似乎https://developer.apple.com/documentation/swiftui/view/contextmenu(menuitems:)是专为此任务设计的,但只有右键单击才能触发上下文菜单。
如何contextMenu
在 macOS 上通过左键单击来触发?谢谢!
Rya*_*yan 19
您可以为该类型的 UI 使用特定的菜单样式。如果你想隐藏指示器,只需输入 false 即可。
Menu("Label") {
Button("Buttons") { }
}
.menuStyle(BorderlessButtonMenuStyle())
.menuIndicator(.hidden)
.fixedSize() // Otherwise will be the width of your menu options.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2778 次 |
最近记录: |