2

I want the Status Bar of my app to have the exact same color as my Navigation Bar. The way I found to change the color of the Status Bar was just by creating a view in the size of the Status Bar and change the background color.

However even though I use the color picker from the Nav bar to set the color of the view I get 2 totally different colors as seen in the picture below. enter image description here

I've tried mixing with the color picker, changing opacity etc, however I'm never able to hit the correct color. Any ideas on how I can get the exact same color for the status bar?

Mr Riksson
  • 560
  • 3
  • 10
  • 29
  • 1
    Try setting your nav bars translucent property to no -- http://stackoverflow.com/questions/21734399/ios7-nav-bar-translucent-no – MendyK May 21 '15 at 23:24

2 Answers2

1

The color of the UIStatusBar is automatically set to match the color of the UINavigationBar when you set the value of self.navigationController.navigationBar.barTintColor. Is there a reason you need to set them separately?

socaljoker
  • 304
  • 2
  • 11
  • 1
    No, this doesn't work for me. barTintColor is set successfully to light gray, but status bar remains white. – Alyoshak Apr 09 '20 at 23:15
0

You can do the following:

  1. Create an UIImage containing only the color you want with a size of 64x1. You could render that image in code.
  2. Set the image as a background image for the navigationBar. Something like: navigationController.navigationBar.setBackgroundImage(image, for: .default)
JTea
  • 234
  • 2
  • 5