0

Possible Duplicate:
iPhone Navigation Bar Title text color

I am trying to change the text color of the navigation title bars in my application. I have managed to do this in iOS 5 using the new appearance API's, but having looked at various threads on how to do so on iOS 4 I am still lost.

I would like to be able to set the text color for the UINavigationBar on all of my View Controllers to a certain color, for iOS 5 I used the appearance method in my AppDelegate, but completely unsure how to do this for iOS 4.

Can anybody help please?

Community
  • 1
  • 1
merrick_s
  • 59
  • 6
  • Try Erik B's answer to this question: http://stackoverflow.com/questions/599405/iphone-navigation-bar-title-text-color You have to add it to each view controller though. – lseidman May 06 '12 at 00:16

2 Answers2

1

Prior iOS 5.0 I think you have to use a custom view like a UILabel customized like you want and set it to the navigation bar with:

 [self.navigationItem setTitleView: myLabel];

You can see the doc here.

Jonathan Naguin
  • 14,526
  • 6
  • 46
  • 75
0

You can do what Aguin said, and change the color of your label.

Hint: Put in your header:

#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

Then change the color of your label with:

[self.navigationItem setTitleView: myLabel];
UIColor* titleColor = UIColorFromRGB(0xff6600); //An orange color for example
myLabel.textColor = titleColor;
jcdmb
  • 3,016
  • 5
  • 38
  • 53