Scale text in your interface automatically by creating fonts that support Dynamic Type.
Dynamic Type allows the user to choose the size of textual content displayed on the screen so they don't have to squint or strain their eyes when reading. Apps that support Dynamic Type also provide a more consistent reading experience.
To add support for Dynamic Type in your app, you need to use scaled fonts. A scaled font can be created from the system font or a custom font.
How to Use a Scaled System Font
Using the scaled system font is recommended when supporting Dynamic Type because it’s designed to look good at any size (for more information, see Typography). Plus, by using the system font you provide consistency with the system and other apps.
You should also use text styles when adding Dynamic Type support to your app. A text style describes the intention of the text, such as
title1, and lets the system know how best to adjust the size of the text.
If you’re using Interface Builder, select the text style from the font drop down, then mark the Dynamic Type option Automatically adjust font.
If you want to do the same in your source code, use
preferred. This method returns an
UIFont that you can assign to a label, text field, or text view. Next, set the
adjusts property on the text control to
true. This tells the text control that it should adjust the text size based on the Dynamic Type setting provided by the user.
How to Use a Scaled Custom Font
Dynamic Type also works with custom fonts—that is, any font that isn’t the system font. If you use a custom font in your app and want to let the user control the text size, you must create a scaled instance of the font in your source code.
To create a scaled custom font, call
scaled, passing in a reference to the custom font. You can use this call on the
default font metrics or you can specify a text style; for instance,
label. You must also set the
adjusts property to
true on the text control in order to see the effects of Dynamic Type.