问题
I'm adding a segmented control to a navigation bar in my iPhone app. By default the color of the segmented control matches the color of the navigation bar. I want to match the color of the segmented control to other buttons in the navigation bar (like the back navigation button).
Can anyone tell me an RGB value (or a system color) that matches the default color of UIButtonBarItems that have been added to a UINavigationBar with a style of UIBarStyleDefault?
回答1:
After a while, I realized that the iPhone was applying a blue gradient to the button, so the tint needed to be pretty gray. I finally hit on this HSV combination which is pretty darn perfect. Note that as per the documentation, all values are specified as float values between 0 and 1.
Hue: 0.6
Saturation: 0.33
Value: 0.69
Alpha: 0
I hope this saves a couple hours of work for some other developer.
回答2:
I use this one:
[UIColor colorWithHue:0.6 saturation:0.33 brightness: 0.65 alpha:1.0];
回答3:
Set the tint color like so:
self.navigationController.navigationBar.tintColor = nil
It will give you the default color and the gradient shade as well.
回答4:
Teach someone to fish.
Check your System for an App called Digital Color Meter or something like that. You can use this to get RGB values from colors on screen.
回答5:
To save some more time, the RGB value for that is:
RGB(118, 141, 176).
If you want to recreate the colour for the 'down' state of the button bar, the RGB value is:
RGB(0, 23, 73).
The gradient I'm not sure about, but this is the base colour.
来源:https://stackoverflow.com/questions/905158/what-is-the-default-color-for-navigation-bar-buttons-on-the-iphone