How can I make a navigation bar's color any color I want?
I created a navigation bar programmatically, and as far as I know, you can only make it "UIC开发者_C百科olor BlackColor" or "WhiteColor" or whatever. So the options are limited. Is there a way to be able to choose from a color palette or something, or use RGB sliders or some way to have thousands of color options?
Sure. You can make an arbitrary UIColor like so:
UIColor *theColor = [UIColor colorWithRed:0.5f
green:0.75f
blue:0.0f
alpha:1.0f];
You can set the color by using the command:
navigationController.navigationBar.tintColor = [UIColor colorWithRed: green: blue: ]
Or the pre made colors in UIColor by typing:
[UIColor blueColor];
"blue" being able to be replaced with many basic colors like black, red, grey, green, etc.
But if you want an image as the background of the NavBar, you need to make a custom class that is a subclass of UINavigationBar.
精彩评论