appearance proxy not working as intended for UIButton font
Asked Answered
P

2

0

im currently styling my app via the appearance proxy and i ran into this problem: when i set properties on the UIButton appearance my font is ignored:

[buttonAppearance setTitleColor:darkColor forState:UIControlStateNormal];
[buttonAppearance.titleLabel setFont:[UIFont fontWithName:@"Helvetica Neue" size:10.0]];

the first line is applied properly (darkColor is some UIColor), but my font change is ignored completely. When i copy the line into my ViewController and apply it to a concrete button it works fine.

Am i missing something?

any help appreciated! ty

Pickax answered 15/6, 2013 at 21:11 Comment(0)
C
3

The font name is wrong, it should be HelveticaNeue, without the space between.

In the future if you want to see other iOS font names you should check this website piece of code

EDIT

After a closer look I realized that you are trying to set the appearance of the button's title which is a UILabel, sadly UILabel doesn't have the font property in the UIAppearance proxy and that's why the font doesn't work.

Cortes answered 15/6, 2013 at 22:35 Comment(2)
i guess not, because Helvetica Neue is the proper font family name, which defaults to the medium helvetica neue. even more important is the fact that it doesn't work when i change it to either @"HelveticaNeue-Light" or your @"HelveticaNeue" for the appearance proxy BUT all of them work when directly applied to a buttons title label. (with the exact same method call given above)Madriene
hmmm wierd - ButtonAppearance.titleLabel setFont:[UIFont fontWithName:fontname size:13.0]] definitely works on ios6.1.3 for meNecessitarianism
H
1

I have found this class TWTButton.h, who resolved my problems adding a new appearance selector [setTitleFont:] to the UIButton class.

buttonAppearance = [TWTButton appearance];
[buttonAppearance setTitleFont:[UIFont systemFontOfSize:10.0f]];

You may read more about this here : http://toastmo.com/blog/2013/01/17/uiappearance/

Hide answered 28/1, 2014 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.