Post

Troubleshooting Text in All Caps

I wrote a post a while ago on how to add a button to a list section title. When I originally implemented this, I was using NavigationLink to display the results on a new screen to edit the entry. Eventually I moved to a sheet, preferring a pop-up over a the horizontal scrolling. When I made the change, I ran into an interesting problem: everything on my new sheet was capitalized!

It turns out that when you display a sheet from within the Section label view, the sheet content inherits the .uppercase setting and displays all text in .uppercase.

Thankfully, the solution to this was rather simple. All I needed to do was add .textCase(.none) to the sheet’s view and that solved the problem.

1
2
3
4
.sheet(isPresented: $showEditor) {
    HabitEditorView(habit: nil, routine: routine)
        .textCase(.none)
}

Anything within the view that should be capitalized (Form, List, Section, etc) will correctly show in caps, but everything else will be back to normal.