I am implementing accessibility dynamic fonts for UILabel
with custom font in my iOS project.
Looks like this:
let pointSize = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .footnote).pointSize
myLabel.font = UIFont(name: "my-custom-font", size: pointSize)
The issue is that this code is applied even if Larger Accessibility sizes
is disabled in device settings, which is no good for me.
How could I apply this code only if Larger Accessibility sizes
is enabled?
2
Answers
You can check it in the following way:
Objective-C code, you can convert it to swift. and have your own check as you need.
The second way around it is to check this with, trait collections’s preferredContentSizeCategory property. You can respond to these changes in traitCollectionDidChange and make UI change accordingly.
There is an easier way actually: