how do I create a new text style?
Asked on 2024-07-30
1 search
To create a new text style, you can follow these steps based on the information provided in the WWDC sessions:
-
Using UIKit:
- Set the
adjustsFontForContentSizeCategoryproperty on aUILabeltotrueso that the label automatically updates its font when the system text size changes. - Set the font by using
preferredFont(forTextStyle:)with your desired style. - Consider setting the
numberOfLineson the label to zero to allow the text to take as many lines as it needs and avoid truncations.
For more details, you can refer to the session Get started with Dynamic Type.
- Set the
-
Using SwiftUI:
- Use the
fontmodifier with a built-in text style. For example, you can pass thetitleparameter to select the title style.
For more details, you can refer to the session Get started with Dynamic Type.
- Use the
-
Text Highlighting:
- Use the new
textHighlightStylefor the range of text that should be highlighted andtextHighlightColorSchemefor the color used to render the highlight. There are predefined color schemes in addition to the default, which uses the tint color.
For more details, you can refer to the session What’s new in UIKit.
- Use the new
-
Attributed Strings:
- You can add a color attribute to an attributed string to highlight parts of the text.
For more details, you can refer to the session Build multilingual-ready apps.
Relevant Sessions
If you need more specific details or have another question, feel free to ask!

Get started with Dynamic Type
Dynamic Type lets people choose their preferred text size across the system and all of their apps. To help you get started supporting Dynamic Type, we’ll cover the fundamentals: How it works, how to find issues with scaling text in your app, and how to take practical steps using SwiftUI and UIKit to create a great Dynamic Type experience. We’ll also show how you can best use the Large Content Viewer to make navigation controls accessible to everyone.

What’s new in UIKit
Explore everything new in UIKit, including tab and document launch experiences, transitions, and text and input changes. We’ll also discuss better-than-ever interoperability between UIKit and SwiftUI animations and gestures, as well as general improvements throughout UIKit.

Build a spatial drawing app with RealityKit
Harness the power of RealityKit through the process of building a spatial drawing app. As you create an eye-catching spatial experience that integrates RealityKit with ARKit and SwiftUI, you’ll explore how resources work in RealityKit and how to use features like low-level mesh and texture APIs to achieve fast updates of the users’ brush strokes.
