I have a List
with Sections
:
List {
ForEach((1...3), id: .self) { _ in
Section(
header: Text("My Section")
.font(.system(.title3))
.fontWeight(.bold)
.foregroundColor(.primary),
content: {
ForEach((1...5), id: .self) { _ in
Text("My Row")
}
}
)
}
}
Here is the result on an iPhone 8 simulator with iOS 14.5:
And here the result on an iPhone 8 simulator with iOS 15:
I want iOS15 list to be equal to iOS14.5 one. I can remove horizontal padding by adding .listStyle(PlainListStyle())
to the List
but the header of the section still have different vertical padding.
Is there a way to have the same vertical header padding as iOS14.5 ?
Environment:
- iOS 15 RC
- XCode 13 RC
3
Answers
Finally, what suited me the most was to add
In AppDelegate
didFinishLaunchingWithOptions
functionChange list’s style to
GroupedListStyle
using the.listStyle()
modifier.Header without gray backgrounnd
More info
https://developer.apple.com/documentation/swiftui/liststyle
You can try setting the
defaultMinListHeaderHeight
in the environment: