I created a navigation bar programmatically, and as far as I know, you can only make it "UIColor 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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top