Dynamically Mocking iOS Dynamic Type System Text Size (UIContentSizeCategory)
How embarrassing! I was looking at some out-of-date iOS 9.x documentation and missed that UITraitCollection
gained init(preferredContentSizeCategory: UIContentSizeCategory)
and var preferredContentSizeCategory: UIContentSizeCategory
in iOS 10, which was helpfully pointed out to me by Brandon Williams. This addresses my needs perfectly.
One easy way is to write a wrapper around UIFontMetrics
and route all UIContentSizeCategoryDidChange
notifications through that. It allows for unit/UI testing various Dynamic Type settings. I wrote about it here.