Reputation: 5200
This works. It sets the font and the colour correctly:
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
COA_TITLE_FONT(17.0),
NSFontAttributeName, [UIColor brownColor], NSForegroundColorAttributeName, nil]];
This makes the title go white - or at least that's what it looks like against a coloured background:
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
COA_TITLE_FONT(17.0),
NSFontAttributeName, [UIColor colorWithRed:62.0f green:116.0f blue:140.0f alpha:1.0f], NSForegroundColorAttributeName, nil]];
I use the RGB extensively in IB to set labels, buttons, etc., but can't set this one that way. I wonder if it is somehow getting a wrong tint colour, but the brown colour looks... well, brown.
Upvotes: 0
Views: 124
Reputation: 6396
You need to use decimal values for RGB. Divide all your floats by 255.0. Right now you're essentially setting it to pure white, as it just reads your >1 values as 1.0f
[self.navigationController.navigationBar setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
COA_TITLE_FONT(17.0),
NSFontAttributeName, [UIColor colorWithRed:62.0f/255.0f green:116.0f/255.0f blue:140.0f/255.0f alpha:1.0f], NSForegroundColorAttributeName, nil]];
Upvotes: 2