在SwiftUI 2的导航栏中,我有一个包含多个部分的列表。所有部分都有标题,但是我希望顶部部分永远不会关闭,并且元素永远不会被隐藏。这仅适用于第一个标题,并且我希望折叠指示符/折叠符号消失或隐藏。
在SwiftUI 2中是否可以实现这一点?
我希望在macOS和iPadOS上实现这一点。
我希望我的问题很清楚。 一如既往,非常感谢你。
添加了一些图片以显示一个部分标题有关闭和打开按钮。
@State var agendaViews: [String] = ["Agenda", "Client", "Next Client"]
@State var treatmentViews: [String] = ["Treatment", "Products", "Merchandising"]
@State var selectionAgenda: String?
var body: some View {
NavigationView {
VStack {
List(selection: $selectionAgenda) {
Section(header: ListHeader()) { // <<<<<<< For this section no Close Icon and No way to close this section.
ForEach(agendaViews, id: \.self) { string in
NavigationLink(destination: DetailsView(test: string)) {
Text(string)
}
}
}
Section(header: ListHeader2(), footer: ListFooter2()) {
ForEach(treatmentViews, id: \.self) { string in
NavigationLink(destination: DetailsView2(test: string)) {
Text(string)
}
}
}
}.listStyle(SidebarListStyle())
}
}
}
struct ListHeader1: View {
var body: some View {
HStack {
Image(systemName: "calendar")
Text("Agenda")
}
}
}
struct ListHeader2: View {
var body: some View {
HStack {
Image(systemName: "person.3")
Text("Clienten")
}
}
}
struct ListFooter3: View {
var body: some View {
Text("===")
}
}
我希望我的问题很清楚。 一如既往,非常感谢你。
添加了一些图片以显示一个部分标题有关闭和打开按钮。