UINavigationBar styling without background images

I am trying to find a way to change the style of my UINavigationBar without using images. I want to create a flat UINavigationBar with a solid color. Is my only choice to subclass UINavigationBar and draw a full NavigationBar myself? I orient iPhone on iOS 6.0.

+4
source share
1 answer

you can use UINavigationBar appearance

here you go, edit rgb color values ​​as needed

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:1/256.0 green:96/256.0 blue:149/256.0 alpha:1.0]]; return YES; } 

Note: this element will not affect the control panel elements, you need to see [[UIBarButtonItem appearance] if you want to change buttons too

 [[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:126/256.0 green:181/256.0 blue:55/256.0 alpha:1.0]]; 
+5
source

All Articles