1 | initial version |
To disable the collapsibility of List Sections in SwiftUI when used within a NavigationView, you can use the following modifier on the List:
.listStyle(GroupedListStyle())
By using the GroupedListStyle(), you can prevent the List Sections from collapsing when using a NavigationView. The code would look something like this:
NavigationView {
List {
Section(header: Text("Section 1")) {
Text("Item 1")
Text("Item 2")
}
Section(header: Text("Section 2")) {
Text("Item 3")
Text("Item 4")
}
}
.listStyle(GroupedListStyle())
}