Skip to content

Strange Behavior with Dynamic Type Updates #402

Description

@nevillco

Hey Zev/Rightpointers! Hope you're doing well. I'm seeing some weird behavior with Dynamic Type and application.enableAdaptiveContentSizeMonitor() I'm wondering if anyone has context on.

I have two StringStyles: one just uses the system body font (UIFont.preferredFont(for: .body)). The other uses a font in the bundle (Lato), and I create a scaled font like this:

let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
let size = descriptor.pointSize
// swiftlint:disable:next force_unwrapping
return UIFont(name: customFont.name, size: size)!

In the demo video attached, I have 4 labels: applying both .adapt(body) and .adapt(control) to each of these styles. I'm also calling application.enableAdaptiveContentSizeMonitor(), so I'm hoping to see the labels responding to changes to Dynamic Type when I return to the app. Weirdly, what I'm seeing is that all 4 labels do adjust their size somewhat in the right direction (larger or smaller), but I still need to leave and recreate the view to get the correct dynamic size. In the video attached, the labels are initially the correct (small) size, and when I move the Dynamic Type slider to the large end, the labels get bigger, but not as big as expected. Once I leave the view and push to a new view, they're the correct size again. I see the same behavior regardless of whichever 2 points on the Dynamic Type slider I use. Any idea what might be causing this weird behavior?

dynamic-type-bug.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions