1

I have at least one UIBarButtonItem's in every UIViewController in my project, everything is in a UINavigationController and the UINavigationBar is blue and the UIBarButtonItem's should be white.

In the simulator they are white... but in device they are lightgray as you can see in the pictures below:

Simulator Simulator

Device Device

They run the exact same code and the exact same ios version ios 8.1.

I am currently setting the tint color in storyboard to white, but Ive also tried:

// In appdelegate
UINavigationBar.appearance().barTintColor = UIColor(hex: 0x4a9bcb, alpha: 1.0)
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName:UIFont(name: "FuturaLT-Bold", size: 16)!, NSForegroundColorAttributeName:UIColor(white: 1.0, alpha: 1.0)]
UIBarButtonItem.appearance().tintColor = UIColor.whiteColor()

// In map viewcontroller viewDidLoad 
self.edgesForExtendedLayout = UIRectEdge.None
self.navigationController?.navigationBar.translucent = false

Which gave the same result.

Please help me understand whats going on.

Arbitur
  • 38,684
  • 22
  • 91
  • 128

2 Answers2

5

I found what was wrong.......... In settings there is an option under General/Accessibility/Increase Contrast called Darker colors... I had that turned on which made tint color darker (of course). So silly.

Arbitur
  • 38,684
  • 22
  • 91
  • 128
0

That is most likely due to alpha (transparency) being on for the top NavigationBar. When the content slides under the top bar it shows a percentage of the underlying view causing your whites to not be white.

You can eliminate that by turning transparency on the NavigationBar off:

self.navigationController.navigationBar.translucent = NO;

or by stopping the content from scrolling under the bar by setting:

edgesForExtendedLayout = UIRectEdgeNone;

See this StackOverflow answer for more details and an explanation of extended layout and transparent navigation bars.

Community
  • 1
  • 1
Cliff Ribaudo
  • 8,932
  • 2
  • 55
  • 78
  • But why is it happening on the device and not in the simulator? – Arbitur Feb 26 '15 at 11:06
  • Not sure but that is definitely alpha/transparency – Cliff Ribaudo Feb 26 '15 at 11:07
  • Do you mean alpha for the navigationbar? In navigationcontroller the navigationbar is opaque – Arbitur Feb 26 '15 at 11:08
  • Yes, that is what I'm referring to – Cliff Ribaudo Feb 26 '15 at 11:08
  • Well the main reason is your content is allowed to scroll UNDER the NavigationBar. You can also prevent that. – Cliff Ribaudo Feb 26 '15 at 11:09
  • mhm, and how do i disable that except setting top bar to "Opaque Navigation Bar"? – Arbitur Feb 26 '15 at 11:11
  • Opaque navigation bar will do it, or set edges for extended layout as shown in my edit. – Cliff Ribaudo Feb 26 '15 at 11:15
  • I really dont think it has with transparency to do, because the gray color is constant and is not changing when scrolling the map, and I always have navigationbar opaque and not translucent which do not allow the view to go under the navigationbar, i tihnk this is a much more diffivult problem than that. – Arbitur Feb 26 '15 at 11:19
  • It absolutely has to do with transparency of the navigation bar. As I answered, you have two options turn transparency off OR stop content from using the space UNDER the navigation bar by setting UIRectEdgeNone – Cliff Ribaudo Feb 26 '15 at 11:21
  • There is a setting on the storyboard for turning off edgesForExtended layout. Did you twiddle that? – Cliff Ribaudo Feb 26 '15 at 11:23
  • The Extended Edges are all unchecked aswell. – Arbitur Feb 26 '15 at 11:25
  • Could be something to do with the images you are using for these buttons... anything weird about them? Are they pure opaque white over pure transparent white background? The hardware rendering on the device might give different results than the software rendering in the simulator. – Clafou Feb 26 '15 at 11:32
  • The images are opaque with black color, I tihnk ive already tried to make them opaque white but Ill test that again. – Arbitur Feb 26 '15 at 12:03
  • I noticed that when I change the NavigationBar tintColor (not barTintColor) when I change its color to blue the items become darker and when set to white nothing different happens than before and when I set it to clearColor the items are invisible. – Arbitur Feb 26 '15 at 12:28