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

Can not set custom font #64

Closed
666tos opened this issue Jul 24, 2014 · 6 comments
Closed

Can not set custom font #64

666tos opened this issue Jul 24, 2014 · 6 comments

Comments

@666tos
Copy link

666tos commented Jul 24, 2014

Adding [super setFont:font]; in setFont: solved issue

@cbpowell
Copy link
Owner

Could you provide a little more background? Setting a MarqueeLabel's font works fine for me using the font property, i.e.self.aLabel.font = [UIFont systemFontOfSize:10];.

Or do you mean custom, non-system fonts added to your app bundle?

@marfurt
Copy link

marfurt commented Aug 27, 2014

I have the same problem using HelveticaNeue-Light in Interface Builder.

Apparently, setting the font property of the label has no effect if it is set to a custom font in Interface Builder.

The workaround is to use a system font in Interface Builder, and then set the property with the desired custom font programmatically:

aMarqueLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:16.0f];

@666tos
Copy link
Author

666tos commented Aug 27, 2014

I use default font in interface builder and set font to custom one programmatically.
But anyway, it doesn't matter if it's system or custom one. It works just fine all over the application.

@cbpowell
Copy link
Owner

Ah, I understand the problem now. Something must not be working as expected in the forwardPropertiesToSublabel method, resulting in the font as set by IB not making it to the subLabel. I'll check it out.

@cbpowell
Copy link
Owner

This was the result of over-reliance on the attributedText property. After a bit of testing, it looks like if a value is set to the attributedText property that the font, textColor, and other style properties simply reference the data stored in the attributed text, rather than actually storing a UIFont/UIColor/whatever object.

I was using attributedText in forwardPropertiesToSublabel with the assumption it did set the style properties. I'm assuming you were using the text property to set just your string at a later point - as of iOS 6 setting the text property also replaces attributedText with an unstyled string, so the style properties stored there were also cleared and reset to default.

Check out release v2.0.4 for the fix. Thanks for pointing it out!

@marfurt
Copy link

marfurt commented Aug 28, 2014

I am using the text property of the UILabel, indeed.

It works correctly now with release 2.0.4, thank you for the fix!

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

3 participants