Post

Replies

Boosts

Views

Activity

How to remove space before SwiftUI List Sections?
I would like to use the built in SwiftUI List and Sections but with all the style and space removed (so I can do this myself). In particular I want the sticky section headings. However, there is always a small space above the sections that I can't remove whatever I do. I am aware there used to be a fix <iOS15, but I can't find a way for iOS16. Here is some example code: struct ContentView: View { var body: some View { List { ForEach(0...10, id: \.self) { value in Section { ForEach(0...10, id: \.self) { innerValue in Text("List item \(innerValue)") } } header: { Text("Section \(value)") .frame(height: 50) .frame(maxWidth: .infinity) .background(Color(.systemGray6)) } } .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) } .listStyle(.plain) .clipped() } } As you can see in this screenshot, I get the nice sticky header, but I get an annoying space between all of the sections, which I want to remove.
4
0
6.2k
Jun ’23