Search code examples
swiftswiftuiios14swiftui-list

SwiftUI Section header - use non uppercase?


Creating a List as follows:

struct ContentView: View {
    var body: some View {
        List {
            Section(header: Text("Header")) {
                Text("Row 1")
                Text("Row 2")
            }
        }
        .listStyle(PlainListStyle())
    }
}

uses uppercase text in the section header.

enter image description here

Is there a way to force the header text to be retain its original case?


Solution

  • 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)