Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange Behavior with Dynamic Type Updates #402

Open
nevillco opened this issue Jan 17, 2021 · 1 comment
Open

Strange Behavior with Dynamic Type Updates #402

nevillco opened this issue Jan 17, 2021 · 1 comment

Comments

@nevillco
Copy link
Contributor

nevillco commented Jan 17, 2021

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
@ZevEisenberg
Copy link
Collaborator

Weird. Nothing immediately jumps out. Keep in mind that BonMot's dynamic type stuff was created before the more recent UIKit APIs for dynamic type metrics, so in addition to debugging this, it's possible that there's a more modern rethink that we could do.

In terms of debugging, you can't go wrong subclassing UILabel and observing its font and attributedText properties to see if anything interesting pops up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants