mrackwitz / MRProgress

Collection of iOS drop-in components to visualize progress
MIT License
2.55k stars 306 forks source link

Bug with custom fonts & smaller text sizes with iOS Dynamic Type #76

Closed objectmethod closed 9 years ago

objectmethod commented 9 years ago

If you change the Text Size to a smaller size for iOS Dynamic Type via Settings -> Display & Brightness -> Text Size, the MRProgressOverlayView's label appears to get cut off and not display the text properly.

mrackwitz commented 9 years ago

Thanks @objectmethod for reporting this issue. Do you want perhaps look into that layouting issue and trying to figure out how to fix that?

mrackwitz commented 9 years ago

I just tried if I can reproduce this issue, but wasn't able to do so. Could you perhaps provide a screenshot and a code snippet how the problem appears for you?

objectmethod commented 9 years ago

Sure.

If we set the Dynamic Type to the lowest setting: https://www.dropbox.com/s/anznbe2prfcj1k0/IMG_0463.PNG?dl=0

And we have the following code: https://gist.github.com/objectmethod/db4658a9d22b2afd0210

I am pretty sure the problem is because we specify our font size and our app does not respect the Dynamic Type at all.

On Nov 1, 2014, at 3:04 PM, Marius Rackwitz notifications@github.com wrote:

I just tried if I can reproduce this issue, but wasn't able to do so. Could you perhaps provide a screenshot and a code snippet how the problem appears for you?

— Reply to this email directly or view it on GitHub https://github.com/mrackwitz/MRProgress/issues/76#issuecomment-61379218.

mrackwitz commented 9 years ago

Ok, so you alter the font, then you should set the text as NSAttributedString by the property titleLabelAttributedText, where you specify something like @{ NSFontAttributeName: [UIFontManager AVENIR_BOOK_SIXTEEN_FONT] } as attributes. This is an undocumented implementation detail, which is originated in the layout code. I will try to either fix or clarify that. Putting all together:

self.hud.titleLabelAttributedText = [[NSAttributedString alloc] initWithString:label attributes:@{
        NSForegroundColorAttributeName: GRAY_TEXT_COLOR,
        NSFontAttributeName:            [UIFontManager AVENIR_BOOK_SIXTEEN_FONT],
        //NSKernAttributeName:            NSNull.null,  // turn on auto-kerning?
    }];

Let me know if this solves your issue.

objectmethod commented 9 years ago

Perfect!

Thanks,

Richard Guy RichardPaulGuy@Gmail.com 770-363-2993

On Nov 3, 2014, at 8:31 AM, Marius Rackwitz notifications@github.com wrote:

Ok, so you alter the font, then you should set the text as NSAttributedString by the property titleLabelAttributedText, where you specify something like @{ NSFontAttributeName: [UIFontManager AVENIR_BOOK_SIXTEEN_FONT] } as attributes. This is an undocumented implementation detail, which is originated in the layout code. I will try to either fix or clarify that. Putting all together:

self.hud.titleLabelAttributedText = [[NSAttributedString alloc] initWithString:label attributes:@{ NSForegroundColorAttributeName: GRAY_TEXT_COLOR, NSFontAttributeName: [UIFontManager AVENIR_BOOK_SIXTEEN_FONT], //NSKernAttributeName: NSNull.null, // turn on auto-kerning? }]; Let me know if this solves your issue.

— Reply to this email directly or view it on GitHub https://github.com/mrackwitz/MRProgress/issues/76#issuecomment-61477046.