Supporting Dynamic Type in iOS Text Views

September 10th, 2018

Filed under: iOS Development | Be the first to comment!

Dynamic Type on iOS lets people adjust the size of text to make text easier to read. Someone with poor eyesight can use larger text if the app supports Dynamic Type.

You can support Dynamic Type in your iOS app without writing any code. You have to do the following things:

  • Use plain text in the text view.
  • Tell the text view to support Dynamic Type in Interface Builder.
  • Choose a Dynamic Type text style as the text view’s font.

You can perform all these tasks from the attributes inspector in Interface Builder. Select your text view from the storyboard or xib file.

TextViewDynamicTypeIB

To use plain text in the text view, choose Plain from the Text menu.

Select the Dynamic Type checkbox to support Dynamic Type. If you build your project at this point, you will most likely get the following warning in Xcode:

Automatically Adjusts Font requires using a Dynamic Type text style

Text views in iOS Xcode projects initially use the system font, which does not support Dynamic Type. You must change the font to use a Dynamic Type text style. Click the button on the right side in the Font text field to open a popover to change the font.

TextViewFontPopover

Use the Font menu to select a text style. There’s a Text Styles group of menu items. Choose one of them as the font for the text view to support Dynamic Type.


Leave a Reply

Your email address will not be published. Required fields are marked *