I'm using ABAddressBookRef
to get information of people for my Phone book. It works properly, but I want to change color of UINavigationBar
of ABPeoplePickerNavigationController
.
我正在使用ABAddressBookRef来获取我的电话簿的人员信息。它工作正常,但我想改变ABPeoplePickerNavigationController的UINavigationBar的颜色。
Is this possible or not? If possible, please tell me how to do it.
这有可能吗?如果可能的话,请告诉我怎么做。
8 个解决方案
#1
7
Set the tint color , like this way....
像这样设置色调颜色....
ABPeoplePickerNavigationController *objPeoplePicker = [[ABPeoplePickerNavigationController alloc] init];
[objPeoplePicker setPeoplePickerDelegate:self];
objPeoplePicker.topViewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];
[self presentModalViewController:objPeoplePicker animated:YES];
Changing the UISearchBar color
更改UISearchBar颜色
if( picker.searchDisplayController == nil )
NSLog(@"searchDisplayController is nil");
if( picker.topViewController.searchDisplayController == nil )
NSLog(@"topViewController.searchDisplayController is nil");
static BOOL foundSearchBar = NO;
- (void)findSearchBar:(UIView*)parent mark:(NSString*)mark {
for( UIView* v in [parent subviews] ) {
if( foundSearchBar ) return;
NSLog(@"%@%@",mark,NSStringFromClass([v class]));
if( [v isKindOfClass:[UISearchBar class]] ) {
[(UISearchBar*)v setTintColor:[UIColor blackColor]];
foundSearchBar = YES;
break;
}
[self findSearchBar:v mark:[mark stringByAppendingString:@"> "]];
}
}
- (void)pickPerson:(BOOL)animated {
foundSearchBar = NO;
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
[[picker navigationBar] setTintColor:[UIColor blackColor]];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects:
[NSNumber numberWithInt:kABPersonEmailProperty],
nil];
[self presentModalViewController:picker animated:animated];
[picker release];
[self findSearchBar:[picker view] mark:@"> "];
}
#2
2
You can use appearance proxies to govern the appearance of the nav bar in the ABPeoplePickerNavigationController
like so:
您可以使用外观代理来控制ABPeoplePickerNavigationController中导航栏的外观,如下所示:
for a red bar with white bar button items:
对于带有白色条形按钮项目的红色条:
[[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setBarTintColor:[UIColor redColor]];
[[UIBarButtonItem appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:[UIColor whiteColor]];
#3
1
You can try this code to change UINavigationBar
Color
您可以尝试使用此代码更改UINavigationBar Color
abPeoplePicker.navigationBar.tintColor=[UIColor redColor];
#4
0
if ([navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
UIImage *backGroundImage = [[UIImage imageNamed:kNavigationBarBackGroundImage] stretchableImageWithLeftCapWidth:5 topCapHeight:5];
[[UINavigationBar appearance] setBackgroundImage:backGroundImage forBarMetrics:UIBarMetricsDefault];
}
This will affect all navigation bars but you set a backgroudn image rather then setting the background image but settintcolor sets only sets the color of the bars
这将影响所有导航栏,但您设置了背景图像,而不是设置背景图像,但settintcolor设置仅设置条形图的颜色
#5
0
You can try this code to change ABPeoplePickerNavigationController Color
您可以尝试使用此代码更改ABPeoplePickerNavigationController Color
objPicker.ViewController.navigationController.navigationBar.tintColor = [UIColor redColor];
or you can set RGB color
或者你可以设置RGB颜色
objPicker.ViewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.274 green:0.270 blue:0.268 alpha:0.8];
#6
0
change color of UISearchBar of ABPeoplePickerNavigationController use like this way....
改变ABPeoplePickerNavigationController的UISearchBar的颜色就像这样使用....
objPicker.ViewController.searchDisplayController.searchBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];
Changing tintColor of UISearchBar inside ABPeoplePickerNavigationController
在ABPeoplePickerNavigationController中更改UISearchBar的tintColor
#7
0
picker.topViewController.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
#8
0
Try this:
尝试这个:
static BOOL foundSearchBar = NO;
- (void)findSearchBar:(UIView*)parent mark:(NSString*)mark {
for( UIView* v in [ subviews] ) {
if( foundSearchBar ) return;
NSLog(@"%@%@",mark,NSStringFromClass([v class]));
if( [v isKindOfClass:[UISearchBar class]] ) {
[(UISearchBar*)v setTintColor:[UIColor blackColor]];
foundSearchBar = YES;
break;
}
[self findSearchBar:v mark:[mark stringByAppendingString:@"> "]];
}
}
- (void)pickPerson:(BOOL)animated {
foundSearchBar = NO;
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
[[picker navigationBar] setTintColor:[UIColor blackColor]];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects:
[NSNumber numberWithInt:kABPersonEmailProperty],
nil];
[self presentModalViewController:picker animated:animated];
[picker release];
[self findSearchBar:[picker view] mark:@" "];
}
#1
7
Set the tint color , like this way....
像这样设置色调颜色....
ABPeoplePickerNavigationController *objPeoplePicker = [[ABPeoplePickerNavigationController alloc] init];
[objPeoplePicker setPeoplePickerDelegate:self];
objPeoplePicker.topViewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];
[self presentModalViewController:objPeoplePicker animated:YES];
Changing the UISearchBar color
更改UISearchBar颜色
if( picker.searchDisplayController == nil )
NSLog(@"searchDisplayController is nil");
if( picker.topViewController.searchDisplayController == nil )
NSLog(@"topViewController.searchDisplayController is nil");
static BOOL foundSearchBar = NO;
- (void)findSearchBar:(UIView*)parent mark:(NSString*)mark {
for( UIView* v in [parent subviews] ) {
if( foundSearchBar ) return;
NSLog(@"%@%@",mark,NSStringFromClass([v class]));
if( [v isKindOfClass:[UISearchBar class]] ) {
[(UISearchBar*)v setTintColor:[UIColor blackColor]];
foundSearchBar = YES;
break;
}
[self findSearchBar:v mark:[mark stringByAppendingString:@"> "]];
}
}
- (void)pickPerson:(BOOL)animated {
foundSearchBar = NO;
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
[[picker navigationBar] setTintColor:[UIColor blackColor]];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects:
[NSNumber numberWithInt:kABPersonEmailProperty],
nil];
[self presentModalViewController:picker animated:animated];
[picker release];
[self findSearchBar:[picker view] mark:@"> "];
}
#2
2
You can use appearance proxies to govern the appearance of the nav bar in the ABPeoplePickerNavigationController
like so:
您可以使用外观代理来控制ABPeoplePickerNavigationController中导航栏的外观,如下所示:
for a red bar with white bar button items:
对于带有白色条形按钮项目的红色条:
[[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setBarTintColor:[UIColor redColor]];
[[UIBarButtonItem appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:[UIColor whiteColor]];
#3
1
You can try this code to change UINavigationBar
Color
您可以尝试使用此代码更改UINavigationBar Color
abPeoplePicker.navigationBar.tintColor=[UIColor redColor];
#4
0
if ([navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
UIImage *backGroundImage = [[UIImage imageNamed:kNavigationBarBackGroundImage] stretchableImageWithLeftCapWidth:5 topCapHeight:5];
[[UINavigationBar appearance] setBackgroundImage:backGroundImage forBarMetrics:UIBarMetricsDefault];
}
This will affect all navigation bars but you set a backgroudn image rather then setting the background image but settintcolor sets only sets the color of the bars
这将影响所有导航栏,但您设置了背景图像,而不是设置背景图像,但settintcolor设置仅设置条形图的颜色
#5
0
You can try this code to change ABPeoplePickerNavigationController Color
您可以尝试使用此代码更改ABPeoplePickerNavigationController Color
objPicker.ViewController.navigationController.navigationBar.tintColor = [UIColor redColor];
or you can set RGB color
或者你可以设置RGB颜色
objPicker.ViewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.274 green:0.270 blue:0.268 alpha:0.8];
#6
0
change color of UISearchBar of ABPeoplePickerNavigationController use like this way....
改变ABPeoplePickerNavigationController的UISearchBar的颜色就像这样使用....
objPicker.ViewController.searchDisplayController.searchBar.tintColor = [UIColor colorWithRed:0.294 green:0.278 blue:0.247 alpha:1.0];
Changing tintColor of UISearchBar inside ABPeoplePickerNavigationController
在ABPeoplePickerNavigationController中更改UISearchBar的tintColor
#7
0
picker.topViewController.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
#8
0
Try this:
尝试这个:
static BOOL foundSearchBar = NO;
- (void)findSearchBar:(UIView*)parent mark:(NSString*)mark {
for( UIView* v in [ subviews] ) {
if( foundSearchBar ) return;
NSLog(@"%@%@",mark,NSStringFromClass([v class]));
if( [v isKindOfClass:[UISearchBar class]] ) {
[(UISearchBar*)v setTintColor:[UIColor blackColor]];
foundSearchBar = YES;
break;
}
[self findSearchBar:v mark:[mark stringByAppendingString:@"> "]];
}
}
- (void)pickPerson:(BOOL)animated {
foundSearchBar = NO;
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
[[picker navigationBar] setTintColor:[UIColor blackColor]];
picker.peoplePickerDelegate = self;
picker.displayedProperties = [NSArray arrayWithObjects:
[NSNumber numberWithInt:kABPersonEmailProperty],
nil];
[self presentModalViewController:picker animated:animated];
[picker release];
[self findSearchBar:[picker view] mark:@" "];
}