我用了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(@"%@%@",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:@"> "];
}