Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CNContactViewController navigation bar different between versions

Our tint color is white. Our app uses CNContactViewController. In our version of the app in the store built with Xcode 7 targeting iOS 8 and 9, if you were iOS 9 we called CNContactViewController. The back button is white but has a gray navigation bar behind it. In our development build using Xcode 8 targeting iOS 9 and 10, there is no gray bar, so the back button is white on top of white and very hard to see the shadow.

Has anyone else experienced changes between Xcode versions/SDK versions that the navigation area of CNContactViewController has changed? Might there be some other change in our app that would have affected this bar?

Edit: here is an image what it looks like in our latest build. I did delete some personal information so that's the boxes in the middle, but you can see at the top left its very hard to see the back button.

enter image description here

Edit: this is how we set the colors throughout the app. The white back button wouldn't be an issue if it also used the bar tint color of Red instead of nothing

    UINavigationBar.appearance().barTintColor = UIColor.red
    UINavigationBar.appearance().tintColor = UIColor.white
    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]

The code we use to push this onto our existing navigation controller that has red bar and white buttons:

let ucvc = CNContactViewController(forUnknownContact: contact)
ucvc.delegate = self
ucvc.allowsEditing = true
ucvc.allowsActions = true
ucvc.alternateName = name()
ucvc.contactStore = CNContactStore()
self.navigationController?.pushViewController(ucvc, animated: true)
like image 600
Jason Hocker Avatar asked Dec 24 '22 01:12

Jason Hocker


2 Answers

I was having the exact same issue. It definitely seems like an iOS 10 bug. Anyways, I found a work around by setting the navigation bar's translucency to false. Then set the background color of the application's main window to whatever color you want the navigation bar to be.

Some code snippets:

UINavigationBar.appearance().isTranslucent = false
UIApplication.shared.delegate?.window??.backgroundColor = UIColor.red
like image 97
Cat Thomas Avatar answered Jan 03 '23 05:01

Cat Thomas


I've solved it like this:

CNContactViewController *vc = [CNContactViewController viewControllerForContact:contact];
vc.delegate = self;

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    for (UIView *view in [vc.navigationController.navigationBar subviews]) {
        view.tintColor = [UIColor darkTextColor];

        view.backgroundColor = [UIColor redColor];
    }
});

[self.navigationController pushViewController:vc animated:YES];
like image 41
MauritsK Avatar answered Jan 03 '23 06:01

MauritsK