2

I've home view controller shown in image 1.

Image 1

When user clicks on bar button another view controller is presented using presentViewController: method. This is CNContactPickerViewController which is completely native (shown in image 2).

Image 2

How to change the color of UINavigationBar for this controller? I've tried below approach but didn't worked :

  1. Changed navigation bar color in Appdelegate
  2. Changed navigation bar color in global file that is inherited by controller.

I've used below code :

 [self.navigationBar setTranslucent:NO];

    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavigationBarBackground"]
                       forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];

    [self.navigationBar setShadowImage:[UIImage new]];
    [self.navigationBar setTintColor:kBlackColor];
    [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor blackColor], NSForegroundColorAttributeName,nil]];

Also, when I run the app on device iPhone 6S iOS 9.3.2 the CNContactPickerViewController doesn't shows group button on navigation bar as shown in simulator.

How to change color of Cancel button on CNContactPickerViewController?

I've got answer to above question. Now, the pending thing is how to change color of tableview section as well as cell of CNContactPickerViewController.

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177

1 Answers1

4

Finally, I got it after doing lots of R&D. I've used below code for making Navigation Bar of CNContactPickerViewController red color.

    [[UINavigationBar appearance] setTranslucent:NO];
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:213/255.0f green:38/255.0f blue:46/255.0f alpha:1.0]];
    [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIColor whiteColor], NSForegroundColorAttributeName,nil]];
    [[UINavigationBar appearance] setTintColor:kWhiteColor];
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
  • 1
    This will work fine, but a word of warning that this will change these properties for ALL instances of UINavigationBar, not just the CNContactPickerViewController. – user1898712 Sep 11 '17 at 11:45