UINavigationBar default color

2019-06-15 07:38发布

问题:

I'm just wondering what UINavigationBar's default color is (on the iPhone).

I can't find it anywhere, and calling CGColorGetComponents() on navigationBar.tintColor.CGColorRef has no effect.

For example, if I programmatically set the color to, let's say, red, how do I get it back to normal?

Any help appreciated.

回答1:

To get the default look, you'd set the tintColor to nil.

It's not possible to set it to an instance of UIColor and have it look completely the same as in the default style, because the button colors are slightly different in the default look. For example, UIBarButtonItems with 'Done' button style have a different color than when you explicitly set a tint color that would otherwise resemble the default color of the bar itself.

Also note that the default tint color is different on iPad (and might change in future versions of iOS).