更新时间:2022-12-11 17:56:31
终于找到了 MenuButton
,它对 MacOS 中的 SwiftUI 起到了作用.
Finally found MenuButton
which does the trick for SwiftUI in MacOS.
MenuButton(label: Title(), content: {
Button(action: {
print("Clicked an item")
}) {
Text("Menu Item Text")
}
})
.menuButtonStyle(BorderlessButtonMenuButtonStyle())
... 为我的可点击按钮使用自定义视图 Title()
.
... with using a custom View Title()
for my clickable button.
struct Title: View {
var body: some View {
HStack
{
Text("Title")
}
}
}