iOS — Dynamic text sizes done right

Guntis T
2 min readSep 26, 2022

--

App accessibility is a cool thing. Sadly, it always seems like an extra hassle.

One of the apps I develop is within a Health domain, thus it seemed kinda wrong that it did not have a text sizes adjustment based on the iOS Accessibility settings.

Thus, it was time to do it, and do it the right way. Since then, I've been using this way in all my other apps, to seamlessly add support for text size adjustment.

So I created a class:

And then I in the AppDelegate I have such implementation in mentioned methods:

That helps me react to any font changes, both on cold start and later app openings in foreground.

Whenever the font size is changed, it will send a notification about it, to whoever listens.

Then I can create base classes for UIViews, UITableViewCells, etc. Basically — for every class, that needs to adjust due to font size change.

And then inside any view, that inherits base class, I can use such code:

This makes the font usage more generic, but also makes the views more responsive to different font sizes.

Let me know if you have any more questions or comments regarding this functionality.

As always, please Follow, for some other interesting articles!

--

--