iosuibuttonuiappearance

appearance proxy not working as intended for UIButton font


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


Solution

  • 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.