开发者

iPhone - People picker, is it possible to change the naviagtion bar color and text?

A quick iPhone questio开发者_开发知识库n, 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"


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.


- (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];   
}


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" ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜