UINavigationBar with solid color - ios 7

ios, objective-c, uinavigationbar, uinavigationcontroller, uistoryboard

Solution

This is the right way to do it. User `appearance` proxy methods.

[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[self.navigationController.navigationBar setTranslucent:NO];

Thats all & you are done. Use whatever colour you want. The above code makes the NavigationBar as opaque (i.e. Solid color).

Problem

I'm using an `UINavigationController` with its default `UINavigationBar` and I'm trying to turn the translucent effect off, so I can have a solid color on it. Apparently, it doesn't work with code but it is possible with storyboard with just one click (weird ?!!) my code: ``` UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:APP_DELEGATE.map]; [navController setToolbarHidden:YES]; [navController.navigationBar setTranslucent:NO]; [navController.navigationBar setBarTintColor:[UIColor turquoiseColor]]; // [[UINavigationBar appearance] setBarTintColor:[UIColor turquoiseColor]]; | also doesn't work ``` Why doesn't it work ? How can I fix that ? Thanks.

Original source