SwiftUI Section header - use non uppercase?
There's a textCase(nil) modifier on Section that honours the original text case, which works on iOS 14
From Apple's developer forums: https://developer.apple.com/forums/thread/655524
Section(header: Text("Section Title")) {
[...]
}.textCase(nil)
For a solution that works with both iOS 13 and 14, you can make a custom modifier that only sets the textCase for iOS 14:
struct SectionHeaderStyle: ViewModifier {
func body(content: Content) -> some View {
Group {
if #available(iOS 14, *) {
AnyView(content.textCase(.none))
} else {
content
}
}
}
}
And then you can apply it to your section like this:
Section(header: Text("Section Name")) {
...
}.modifier(SectionHeaderStyle())
This is an adapted version of a suggestion from apple forums: https://developer.apple.com/forums/thread/650243