SwiftUI List section headers changed to uppercase.

I'm targeting iPad ios 14, with this test code:


Code Block
struct ContentView: View {
@State var arr1: [String] = ["one", "two", "three"]
@State var arr2: [String] = ["four", "five", "six"]
var body: some View {
List {
Section(header: Text("first section")) {
ForEach(arr1, id: \.self) { s in
Text(s)
}
}
Section(header: Text("second section")) {
ForEach(arr2, id: \.self) { s in
Text(s)
}
}
}
}
}


Is there a way to make the section headers display what I put in the Text, not change it to uppercase?

Replies

Please try this.
Code Block
var body: some View {
List {
Section(header: Text("first section")) {
ForEach(arr1, id: \.self) { s in
Text(s)
}
}
.textCase(nil)
Section(header: Text("second section")) {
ForEach(arr2, id: \.self) { s in
Text(s)
}
}
.textCase(nil)
}
}


Add a Comment
great, it works. Thanks a lot. What a strange default behavior though.