Search code examples
objective-cfontsuinavigationcontrolleruinavigationitem

Color of custom font in navgation controller (setTextColor): gray instead of white


I am trying to set custom font and color (white) for font in my app's navigation bar title. Instead of white I get gray text color.

Here is the code I'm using to set custom font:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
label.textAlignment = UITextAlignmentCenter;
label.adjustsFontSizeToFitWidth = NO;
label.minimumFontSize = 10.0;
[label setFont:[UIFont fontWithName:@"HelveticaNeueLTCom-MdCn" size:24.0]];
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor whiteColor]];
[label setText:@"View title"];
[self.navigationItem setTitleView:label];

Same thing happened when I tried to set custom font color in UITableView sections.

I know about some problems with Helvetica Neue in iPhone apps development but the color of this font works well in other parts of my projects.

Am I missing something here?


Solution

  • The problem was that I've (deliberately) overriden default font for the whole application as described in this answer.

    The solution was to remove this override (all the #import's and the remove .m file from the target, or just delete both of the class files.