Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8: Cannot change the navigation bar at all of the ABPeoplePickerNavigationController

I try to change the color of the ABPeoplePickerNavigationController navbar to my app colors. However no changes occur. Even when I try to hide it or at least change the status bar tint color, nothing happens. Why?

- (ABPeoplePickerNavigationController *)peoplePicker
{
    if(!_peoplePicker){
        _peoplePicker = [[ABPeoplePickerNavigationController alloc]init];
        _peoplePicker.peoplePickerDelegate = self;
        _peoplePicker.navigationBar.hidden = YES;
    }
    return _peoplePicker;
}

I lazy instantiate my navigation controller and the other method calls like dismiss view controller etc. work fine.

EDIT: This is my current code (for the bounty). No color changes happen like this:

- (ABPeoplePickerNavigationController *)peoplePicker
{
    if(!_peoplePicker){
        _peoplePicker = [[ABPeoplePickerNavigationController alloc]init];
        _peoplePicker.peoplePickerDelegate = self;
        _peoplePicker.navigationBar.tintColor = [UIColor blackColor];
    }
    return _peoplePicker;
}

- (IBAction)addressBookButtonClicked:(id)sender {
    [self presentViewController:self.peoplePicker animated:YES completion:nil];
}

Doesn't this work anymore on iOS8?

like image 222
MichiZH Avatar asked Dec 20 '22 11:12

MichiZH


1 Answers

Actually, thanks to the comment above, I realized that an appearance proxy should work like so:

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

Just put that in the viewDidLoad method of the View Controller from which you are instigating the ABPeoplePickerView. This will also work for MFMailerView as well. My code that I'm using to style my bars properly is:

[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont
                                                                       fontWithName:@"Helvetica Neue" size:12], NSFontAttributeName,
                            [UIColor whiteColor], NSForegroundColorAttributeName, nil];

[[UINavigationBar appearance] setTitleTextAttributes:attributes];
like image 75
Keaton Burleson Avatar answered Dec 24 '22 01:12

Keaton Burleson