Label with large title text style doesn't resize the font size when Dynamic Type setting changes

Originator:stefan.kieleithner
Number:rdar://43682426 Date Originated:24-Aug-2018 03:30 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:11.4.1 & 12b10
Classification:Other Bug Reproducible:Always
 
Summary:
When creating a UILabel, with the font set to a preferred font with text style UIFontTextStyleLargeTitle, adjustsFontForContentSizeCategory is not honored when the Dynamic Type font size setting is changed.

Consider the following code:
let label = UILabel()
label.text = “Text”
label.font = UIFont.preferredFont(forTextStyle: .largeTitle) 
label.adjustsFontForContentSizeCategory = true

When the label is shown, and the Dynamic Type setting is changed (either via the device’s Settings.app, or via the Accessibility Inspector), the label does not update its font size, for the new content size category.

As a workaround, the font on the label can be set again, every time the Dynamic Type setting changes, like this:

NotificationCenter.default.addObserver(forName: .UIContentSizeCategoryDidChange, object: nil, queue: nil) { notification in
    label.font = UIFont.preferredFont(forTextStyle: .largeTitle)
}

This shouldn’t however be needed, since adjustsFontForContentSizeCategory has been enabled, and the font was vended by UIFont.preferredFont(forTextStyle:).

Everything works fine when using a different text style apart from UIFontTextStyleLargeTitle.

Steps to Reproduce:
- Run the attached sample project.
- Change the Dynamic Type font size via the Accessibility Inspector.


Expected Results:
The label with the large title text style resizes its font, to match the new Dynamic Type setting.

Actual Results:
The label with the large title text style does not resize its font. 
While all the other labels (using all the other available UIFontTextStyles) do change.

Version:
11.4.1 & 12b10

Notes:

Comments

Example project: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/43682426%20-%20Label%20with%20large%20title%20text%20style%20doesn't%20resize%20the%20font%20size%20when%20Dynamic%20Type%20setting%20changes

By stefan.kieleithner at Aug. 24, 2018, 1:33 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!