在SwiftUI中,有一个叫做菜单的东西,你可以在里面有按钮、分隔符、其他菜单等等.下面是我正在构建的一个例子:
import SwiftUI
func testing() {
print("Hello")
}
struct ContentView: View {
var body: some View {
VStack {
Menu {
Button(action: testing) {
Label("Button 1", systemImage: "pencil.tip.crop.circle.badge.plus")
}
Button(action: testing) {
Label("Button 2", systemImage: "doc")
}
}
label: {
Label("", systemImage: "ellipsis.circle")
}
}
}
}
因此,在SwiftUIplayground 应用程序中,他们有这个菜单:
我的问题是:
How did they make the circled menu option?我还在菜单中发现了几个类似于这组水平按钮的例子,如下所示:
HStack和其他明显的try 都以失败告终.我已经考虑过添加MenuStyle,但苹果的文档非常缺乏,只显示了一个在菜单按钮上添加红色边框的示例.反正我也不确定这条路是不是对的.
我只能让分隔符()和按钮()显示在菜单中:
我也只能找到显示这两个选项的代码示例,尽管在应用程序中看到了其他选项的示例.