admin管理员组文章数量:1435859
I’m trying to create a simple dropdown button in SwiftUI on macOS. Normally I would expect to use something like this:
MenuButton("☰") {
Button(action: { print("Something") }) {
HStack {
Image(systemName: "questionmark.circle")
Text("Something")
}
}
Button(action: { print("Something Else") }) {
HStack {
Image(systemName: "exclamationmark.circle")
Text("Something Else")
}
}
}
.menuButtonStyle(BorderlessButtonMenuButtonStyle())
The .menuButtonStyle(BorderlessButtonMenuButtonStyle())
shows only the menu icon (☰)
without the drop down
However, MenuButton
has been deprecated in favour of Menu
, which is fine, but I then need to modify it with .menuStyle
, and can’t find the equivalent of BorderlessButtonMenuButtonStyle
What would be the equivalent for Menu
to suppress the drop down arrow?
I’m trying to create a simple dropdown button in SwiftUI on macOS. Normally I would expect to use something like this:
MenuButton("☰") {
Button(action: { print("Something") }) {
HStack {
Image(systemName: "questionmark.circle")
Text("Something")
}
}
Button(action: { print("Something Else") }) {
HStack {
Image(systemName: "exclamationmark.circle")
Text("Something Else")
}
}
}
.menuButtonStyle(BorderlessButtonMenuButtonStyle())
The .menuButtonStyle(BorderlessButtonMenuButtonStyle())
shows only the menu icon (☰)
without the drop down
However, MenuButton
has been deprecated in favour of Menu
, which is fine, but I then need to modify it with .menuStyle
, and can’t find the equivalent of BorderlessButtonMenuButtonStyle
What would be the equivalent for Menu
to suppress the drop down arrow?
1 Answer
Reset to default 1As per the documentation (which may be somewhat innacurate since .buttonStyle(.borderless)
does display a down arrow):
borderlessButton Deprecated
Use
menuStyle(_:)
withbutton
andbuttonStyle(_:)
withborderless
.
Menu("☰") {
Button(action: { print("Something") }) {
HStack {
Image(systemName: "questionmark.circle")
Text("Something")
}
}
Button(action: { print("Something Else") }) {
HStack {
Image(systemName: "exclamationmark.circle")
Text("Something Else")
}
}
}
.menuStyle(.button)
.buttonStyle(.plain)
本文标签: macosStyle a plain dropdown menu in SwiftUIStack Overflow
版权声明:本文标题:macos - Style a plain dropdown menu in SwiftUI - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745637887a2667671.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论