iphoneobjective-ciosabpeoplepickerview

How can I change color of UINavigationBar of ABPeoplePickerNavigationController?


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.

Is this possible or not? If possible, please tell me how to do it.


Solution

  • 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

    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:@"> "];
    }