问题描述
- 如何改变ABPeoplePickerNavigationController的UINavigationBar 颜色。
- 我用了
ABAddressBookRef
获取信息,用的还不错,不过我想改变ABPeoplePickerNavigationController
的UINavigationBar
的颜色。能实现吗?怎么实现?感谢帮忙。
解决方案
先设置颜色:
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];
改变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(@""%@%@""markNSStringFromClass([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:@""> ""];}
解决方案二:
你可以设置一张你要的背景颜色的图片然后设置
[navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""navigationBar_bg.png""]forBarMetrics: UIBarMetricsDefault];
这个可以解决你的问题
时间: 2024-10-07 19:11:00