简体   繁体   中英

iOS 9 Contact List buttons White on White

I realize that ABPeoplePicker has changed for iOS 9 but the functionality is still there and working for now. The issue I am having is that the "Group" and "Cancel" buttons are coming up as white on a white background. So very hard to see. The previous controller that this is coming from does make use of white buttons on its nav bar but of course the background is darker.

I have tried to use the following which works under iOS 8 but seems to do nothing under iOS 9:

[[UIBarButtonItem appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:[UIColor blueColor]];

I have tried to directly set it as well with the navigationcontroller.navbar.tintcolor property. That didn't work under 8 or 9.

How can I get these buttons to be visible on the contact page?

Update: I have also tried this which doesn't work either:

[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[ABPeoplePickerNavigationController class]]] setTintColor:[UIColor blueColor]];

Update 2: I tried using the new CNContactPickerViewController and it does the same thing with white on white.

I also faced this issue earlier. To fix this, you need to set tint colour for UINavigation bar like below:

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

ex:

- (void)showContactList 
{

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

    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];

    picker.peoplePickerDelegate = self;

    [self presentViewController:picker animated:YES completion:nil];
}

I don't know how but this worked for me:

// Text color of navigation bar
    let textAttributes = [NSForegroundColorAttributeName:UIColor.color_template_1_2()]
    UINavigationBar.appearance().titleTextAttributes = textAttributes
    UINavigationBar.appearance().tintColor = UIColor.color_template_1_2()

    let contactPicker = CNContactPickerViewController()

    contactPicker.delegate = self
    contactPicker.displayedPropertyKeys =
        [CNContactPhoneNumbersKey]
    self.present(contactPicker, animated: true, completion: {
        let textAttributes2 = [NSForegroundColorAttributeName:UIColor.white]
        UINavigationBar.appearance().titleTextAttributes = textAttributes2
        UINavigationBar.appearance().tintColor = UIColor.white
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM