我尝试使用SwiftUI创建一个菜单,其中包含主要和次要标签的按钮,就像下面的照片一样,所以我将按钮和文本(作为次要标签)嵌入到VStack中,但它不起作用。我该如何在SwiftUI中创建这个视图?
代码
Menu {
Section {
search
}
Section {
// The sort button
Menu {
Picker("Sorting options", selection: $sort) {
ForEach(SortType.allCases, id: \.self) { type in
Label("title", systemImage: "chevron.up")
.tag(type)
}
}
} label: {
// Here I should embed title and subtitle like the photo but I don't know how.
Label("Sort By", systemImage: "arrow.up.arrow.down")
}
}
} label: {
menuLabel
}