Understanding Text Case And Capitalization In SwiftUI

Small details make the difference

Gabriel Theodoropoulos
4 min readAug 29, 2024
Photo by Leah Kelley: https://www.pexels.com/photo/close-up-photo-of-gray-typewriter-952594/

Text plays an essential role in creating intuitive user interfaces and delivering great user experiences in applications. No matter if it’s static or text that users input in text fields and text views, its appearance vastly defines how it’s perceived by users and how well it conveys its message.

There are various ways to alter text’s appearance in SwiftUI. Changing the font style, family, weight, size, or color are the most common interventions of that kind that developers can make. But often, simply modifying the text case or specifying a non-default capitalization rule on user input may have a great level of impact in the overall user experience.

SwiftUI provides two distinct view modifiers in order to set a different text case and capitalization format. They might sound similar up to some level, but the truth is that each one has its own purpose and serves a different cause. So, it’s important to know their details, as well as when and how to use these modifiers.

Changing the text case in static text

By default, text displayed in Text views and Labels can contain both capital and small letters. It might be necessary sometimes, though, to convert and maintain that…

--

--

Gabriel Theodoropoulos

An iOS & macOS app maker writing code in Swift. Author of countless programming tutorials. Content creator. https://serialcoder.dev