2

A quick iPhone question, I currently use a people picker in my application, I use a black navigation bar in my application but the people picker displays in the default blue color.

I have tried:

picker.navigationBar.backgroundColor = [UIColor blackColor];

However it still displays in the blue color.

Is it possible to change the color of the navigation bar on the people picker? Or is it always going to be blue as it is a system Modal view?

EDIT:

Using the following works for the color:

picker.navigationBar.tintColor = [UIColor blackColor];

However using:

picker.title = @"MyText";

or

picker.navigationItem.title=@"MyText";

or

self.title=@"MyText";

Doesn't work, the title always remains as "All Contacts"

Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191

3 Answers3

2

The color of a UINavigationBar is controlled by its tintColor property.

You can change the color of all navigation bars in your app by making a category on UINavigationBar. Just note that all changes you make in a category are applied across all instances of that class in your app.

In your category, in the init method, change self.tintColor.

Since categories change all instances of a class in your app, it will be trickier to change the text with a category. Instead, try setting the title of the target view.

Moshe
  • 57,511
  • 78
  • 272
  • 425
  • do you know if apple store accept apps with changed address book color? – Sefran2 Dec 03 '11 at 09:46
  • @Fran - I think they did, but I'm not certain.At this point, you're not supposed to use categories like that anymore, since iOS 5 adds new ways of customizing native UI controls. – Moshe Dec 03 '11 at 22:57
2
- (void)showNewPersonViewController {
ABNewPersonViewController *picker1 = [[ABNewPersonViewController alloc] init];
picker1.newPersonViewDelegate = self;

UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:picker1];
navigation.navigationBar.tintColor = [UIColor brownColor];
[self presentModalViewController:navigation animated:YES];

[picker1 release];
[navigation release];   
}
BDGapps
  • 3,318
  • 10
  • 56
  • 75
1

for Changing the color of UINavigationController

self.navigationController.navigationBar.tintColor=[UIColor colorWithRed:42/256.0 green:60/256.0 blue:80/256.0 alpha:1.0];

Changing the text of UINavigationController

self.text = @"My New text" ;
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76