1

Notice the change in color

This is a really odd problem and I haven't seen this before (and barely noticed it, you might have to adjust your monitor brightness for this).

I have a UIViewController, embedded in a UINavigationController. It also has a UIToolbar underneath, nothing too fancy. I set the background color and font of the UINavigationBar and other components in AppDelegate (once), like this:

[[UINavigationBar appearance] setBarTintColor:UIColorFromRGBA(0x013060,1)];
[[UIToolbar appearance] setBarTintColor:UIColorFromRGBA(0x013060,1)];
[[UISegmentedControl appearance] setTintColor:UIColorFromRGBA(0xFFFFFF,1)];
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                       [UIColor whiteColor], NSForegroundColorAttributeName,
                                                       [UIFont fontWithName:@"AvenirNext-Regular" size:17.0], NSFontAttributeName,
                                                       nil]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; // back button etc. text color

Pretty standard. Now, if I click the FILTER button (see my image), I open up a modal view, it's a segue and has no code, it's auto-wired up in Interface Builder. That works, then I dismiss that modal view controller again and fall back into the main controller.

Unwanted behavior: The UINavigationBar has changed it's background color now, just subtle, but noticably. Expected behavior: Same color as before.

This stays that way until I end the app. Something happens the first time that controller shows up, that doesn't the second, or vice versa.

My viewWillAppear (is the only thing I have code in, no viewDidLayoutSubviews or viewDidAppear code) is basically empty (no visual tampering happening). So it's not happening there.

James Stone
  • 487
  • 7
  • 16
  • Is it possible you have made any changes to the navigation bar within the modal view through interface builder? – Don Miguel Aug 20 '14 at 11:20
  • The modal is a simple UIViewController, all inferred. Does not get the UINavigationBar due to it being modal. – James Stone Aug 20 '14 at 11:41
  • Is by any chance the navigation bar translucent in any of your view controllers? – F1ank3r Aug 20 '14 at 11:46
  • yes, it's translucent (by default on iOS7), why? – James Stone Aug 20 '14 at 11:49
  • According to this [question](http://stackoverflow.com/questions/21104666/uinavigationbar-appearance-on-modal-not-setting) UINavigationBar setup could be "lost" after presenting a modal view controller. Perhaps you could reset the UINavigationBar settings on hiding the modal. Check the comment on the second answer for this. – Don Miguel Aug 20 '14 at 11:51
  • Don Miguel, I've tried this out now, basically, in viewWillAppear, I reset all the appearances with the same code I have in AppDelegate. But it did not fix the issue, unfortunately. Only removing the translucent property fixes it, but also funnily messes up auto-layout view in Interface Builder and adds a big gap (but works in running app). – James Stone Aug 20 '14 at 11:58

1 Answers1

0

As indicated by F1ank3r in a comment, when I remove the translucent setting from UINavigationBar as well as the UIToolbar and then change the background colors in AppDelegate to something different, they both have the same color, even after viewing the modal and dimissing it.

I still wonder about the original glitch though, no content changes, nothing gets re-aligned, why suddenly change the translucent color of the UINavigationBar?

Either way, since I don't 'need' to have the bars to be translucent here, I can get by with a static background color. Still wondering though. Thanks F1ank3r for the hint.

James Stone
  • 487
  • 7
  • 16
  • No, problem, it looked like a similar problem I had and fixed by removing the translucency. Don't exactly why it happened, though. – F1ank3r Aug 20 '14 at 11:58