Automatic capitalization of List section headers?

It seems that when my app is compiled with Xcode 12.0 beta (12A6159), all of the text in the Section headers are capitalized. This is true even with the new InsetGroupedListStyle list style.

I'm not clear if this was an intentional design change or a bug, but I'm looking for a way to turn this capitalization behavior off. Anyone know if this is possible?

Accepted Reply

Use the following code:
Code Block Swift
Text("Header Title")
.textCase(.none)


Replies

Use the following code:
Code Block Swift
Text("Header Title")
.textCase(.none)


As noted, .textCase(.none) works, but is only available on iOS 14.

Is there any workaround for section title mixed case when building for iOS 13, using Xcode 12?
Here is a view modifier that I am using. So, .bpTextCase(.none) can be used in iOS 13 and 14.

Code Block Swift
extension View {
    func bpTextCase(_ textCase: BPTextCase.Case?) -> some View {
        self.modifier(BPTextCase(textCase: textCase))
    }
}
struct BPTextCase: ViewModifier {
    enum Case {
        case lowerCase
        case upperCase
        
        @available(iOS 14, *)
        var textCase: Text.Case? {
            switch self {
            case .lowerCase:
                return Text.Case.lowercase
            case .upperCase:
                return Text.Case.uppercase
            }
        }
    }
    let textCase: Case?
    func body(content: Content) -> some View {
        Group {
            if #available(iOS 14, *) {
                // This compiles without AnyView but crashes on iOS 13 due to
                // the unknown class in the resulting type.
                AnyView(content.textCase(textCase?.textCase))
            } else {
                content
            }
        }
    }
}


This issue with all upper case section titles appears to be a bug only in the Xcode 12 simulator. When running my app on device using Xcode 12, the section titles display as mixed case without use of the .textCase(.none) modifier.
Correction, section titles are also rendered in upper case when running on an iOS 14 device, but display as mixed case when running on iOS 13 device. They display upper case in simulator because it is also iOS 14 emulation. App is build in Xcode 12 with iOS 13 target.
I think the iOS 14 behavior of capitalizing text inside List headers is consistent with the platform's general look and feel, and should be the default.
For situations where I didn't want this behavior, I created the following extension for both iOS 13 and 14:

Code Block
extension View {
    /// Neutralizes the iOS 14 behavior of capitalizing all text inside a List header
    @ViewBuilder func unCapitalized() -> some View {
        if #available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) {
            self.textCase(.none)
        } else {
            self // no-op on iOS 13 et al.
        }
    }
}

The unCapitalized example only works when built on Xcode 12, but does not render when built on Xcode 11
BPTextCase does not compile on Xcode 11.7