5

I am creating an iPhone app, but my navigation bar has a different color in each view?

I am developing for iOS7 and with Xcode 5.

I have tried to programatically make the navigation bar the same by writing this in the AppDelegate.m file:

[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];

What should I be doing?

2
  • What colour is it, what colour are you expecting, what is the colour of the view? Commented Sep 15, 2013 at 11:54
  • Mostly just an equal color on each screen. Commented Sep 15, 2013 at 12:41

2 Answers 2

12

NavigationBar style is Translucent light (default) or translucent dark. By default, the translucent property is YES, set it to NO and use barTintColor property of navigationbar to set the navbar background with some colour.

Objective-C

self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
self.navigationController.navigationBar.translucent = NO;

Swift 3

navigationController?.navigationBar.barTintColor = UIColor.white
navigationController?.navigationBar.isTranslucent = false
Sign up to request clarification or add additional context in comments.

Comments

3

You need to set the barTintColor property.

You can specify a custom tint color for the navigation bar background using the Tint (barTintColor) field. The default background tint color is white.

also set the property from the top bar to opaque instead of translucent if you want a solid color From iOS7 docs: https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/UIKitUICatalog/UINavigationBar.html#//apple_ref/doc/uid/TP40012857-UINavigationBar-SW1

6 Comments

I have tried that as well, the color changes, but it is not consistent??? It has different shades of the chosen color in each view? :S
sorry but that's iOS7 style. i don't think there is an option to have no shades or you should make an inner view that is below the navigation bar so there is nothing behind the navigation bar.
another option might be to uncheck the under top bars property (extend edges) on your view.
But the color is significant different from each other? Some brownish, other grey'ish, some comepletely black and the background should be the exact same in each view?
Try to set the following property "translucent = NO". This will stop the color shades inherited from underlying views.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.