One way is to set the Appearance of UINavigationBar to the color you want:
[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
And once you return to the previous ViewController (Maybe with -(void)viewWillAppear:(BOOL)animated
) you set it again to the previous color you were using.
I presented the Contact this way:
CNContactStore *store = [[CNContactStore alloc] init];
// Create contact
CNMutableContact *contact = [[CNMutableContact alloc] init];
contact.givenName = @"Someone Name";
CNLabeledValue *contactPhoneNumber = [CNLabeledValue labeledValueWithLabel:CNLabelHome value:[CNPhoneNumber phoneNumberWithStringValue:@"Some number"]];
contact.phoneNumbers = @[contactPhoneNumber];
CNContactViewController *contactController = [CNContactViewController viewControllerForUnknownContact:contact];
contactController.navigationItem.title = @"Add to contacts";
contactController.contactStore = store;
contactController.delegate = self;
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackColor]};
[self.navigationController pushViewController:contactController animated:YES];
Once the contactController is Dismissed the viewWillAppear
is called and you can add there the color restore depending on your needs:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
}