What is the default background color of the navigation bar in iOS 7?

24,119

Solution 1

The default navbar color in iOS 7 is [UIColor colorWithRed:(247.0f/255.0f) green:(247.0f/255.0f) blue:(247.0f/255.0f) alpha:1];

Solution 2

Swift 5

Nav bar color in light appearance:

UIColor(red: 0.969, green: 0.969, blue: 0.969, alpha: 1.0)

Solution 3

To get the tint color of a navigation bar, do this:

[aNavbar barTintColor]

By using this when you set the background color of your menu, you will not have to change it in case you change your navigation bar tint.

Solution 4

Swift 4

I am not sure the color does not change from version to version. In my app I use this:

var navBarDefaultColor: UIColor?

// save:
navBarDefaultColor = self.navigationController?.navigationBar.tintColor

//restore:
self.navigationController?.navigationBar.tintColor = navBarDefaultColor!

Solution 5

Swift 3.0 +

UIColor(red: (247/255), green: (247/255), blue: (247/255), alpha: 1)

Share:
24,119

Related videos on Youtube

Zia
Author by

Zia

Updated on December 29, 2020

Comments

  • Zia
    Zia over 3 years

    I would like to set the background color of a menu to that of the navigation bar. What is the best way to do this?

  • gran_profaci
    gran_profaci almost 10 years
    Do you mean : [UIColor colorWithRed:(247.0f/255) green:(247.0f/255) blue:(247.0f/255) alpha:1]
  • Nikos M.
    Nikos M. almost 10 years
    @gran_profaci there is no difference between your code and my code ;-) f just tells the compiler that this number is a float.
  • lapin
    lapin over 9 years
    Can you explain how do you know it ?
  • Nikos M.
    Nikos M. over 9 years
    @lapin Just take a screenshot and found it with color picker in Photoshop. :-)
  • Michał Miszczyszyn
    Michał Miszczyszyn almost 9 years
    Since colorWithRed:green:blue:alpha: expects floats it should be 255.0f instead of 255.0. The later one is double and results in a compiler warning because of implicit casting. [UIColor colorWithRed:(247.0f/255.0f) green:(247.0f/255.0f) blue:(247.0f/255.0f) alpha:1];
  • Ken M. Haggerty
    Ken M. Haggerty about 8 years
    Is there any way to get this programmatically in case Apple decides to change this in the future?
  • Ahmadreza
    Ahmadreza about 4 years
    For my case it was backgroundColor.