Dynamically Change Fonts for your User (Dynamic type iOS)
Make a good experience a great one
Before we start
Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 13.0, and Swift 5.3
Prerequisites
- You will be expected to be aware how to make a Single View Application in Swift
Terminology
Dynamic type: A system that allows users to globally change the default font size used across iOS
UIFont: A font object
UIFontMetrics: A utility object for obtaining custom fonts that scale to support Dynamic Type
The issue
So many developers don’t use dynamic type (still), and this means that you aren’t respecting a user’s decision to use their chosen font size (possibly for accessibility reasons) — this isn’t a good look and is something you might want to work on!
Worse, we may (as you’ll see in the example below) it is easy to implement dynamic type that does not respond to the user making changes in Settings or Control Center — which is simply an experience which isn’t good enough for your users.