Navigation bar color not setting properly - ios

Why is the navigation bar color coming so weired? Why is it white above and only a bit red at the bottom. I cannot make out if the status bar is overlapping my navigation bar or what. This is the code I used to change the color of the navigation bar background:
[navbar setBackgroundColor:[UIColor redColor]];

Solution
[navbar setBarTintColor:[UIColor redColor]];
[navbar setTranslucent:NO];
Why
The color of a UINavigationBar is set with its barTintColor property.
What you're seeing is the translucent white navigation bar above your red background. The bit at the bottom is where UINavigationBar renders a shadow below the bar view.

I think this image is sufficient to solve your problem.

Related

Make Navigation Bar Opaque with solid bg color

I am trying to set a solid color for the navigation bar but it always appears translucent.
None of SO answers I tried seem to work.
I have tried:
In the App Delegate:
[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:89/255.0 green:196/255.0 blue:197/255.0 alpha:1.0f]];
In my main TableviewController:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:89/255.0 green:196/255.0 blue:197/255.0 alpha:1.0f];
self.navigationController.navigationBar.translucent = NO;
}
I have also unchecked the Translucent option and checked the Opaque option in the attribute inspector.
Following is an image of what I am trying to achieve:
How do I make the navigation bar opaque with a solid background color?
Thanks.
Go to attribute inspector of for Navigation bar and remove check mark from translucent.
Please find in image.
I was also trying to figure it how to make Navigation bar background a solid color. I was trying to change background color from Storyboard - Attribute inspector but that was wrong option.
The Bar Tint color in the attribute inspector changes the background color of navigation controller.

iOS double navigation bar by set translucent OFF

at First:
I work with the storyboard interface builder...
I tried to color my navigation bar like Instagram:
UIColor *mainColorBlue = [UIColor colorWithRed:0.071 green:0.337 blue:0.533 alpha:1];
[[UINavigationBar appearance] setBarTintColor:mainColorBlue];
[[UINavigationBar appearance] setBackgroundColor:mainColorBlue];
But if i set the color to mainColorBlue, it is not this color. I've read in the internet, that it is cause from translucent. So I set translucent to OFF.
But now, my Problem is: If i deactivate the translucent and activate opaque and start the app on my external device, under the navigation bar is another navigation bar. If i switch the translucent to ON again,the second navigation bar isn't shown.
What i have to do, that the second navigation bar disappear?
I resolve the problem.
I added a subview on position 0,0 to color the statusbar.
UIView *statusBarColor = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 64)];
statusBarColor.backgroundColor = mainColorBlue;
[self.view addSubview:statusBarColor];
So this View is displayed under the navigation bar. I removed this code and now it works.

Navigation Bar color change

I am using Xcode 4.5.2 when setting navigation bar color using tint color property .now navigation bar color has the white shadow above my navigation bar color
Please try
[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

Changing the colour of Navigation Controller bottom toolBar

I am trying to change the colour of the bottom bar of my Navigation Controller. I have managed to change the top NavBar in my appdelegate by adding
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.688 green:0.437 blue:0.794 alpha:1.0]];
I want to apply this to the bottom bar also.
You can use [UIToolbar appearance] to set the appearance of UIToolbar
Good luck
I had the same problem, but could escape this by setting a tag for my navigationBar in my storyboard. Then I could change the navigationBar's color like this:
let navigationBar = (self.view.viewWithTag(someNumber) as UINavigationBar)
navigationBar.barTintColor = UIColor.blackColor()
This is not ideal unless you can guarantee that the number of subviews in your view is less than "someNumber". If you can though, then this should work.

Navigation Bar color and a View's color

I'm getting a weird, i have a navigation bar and a view that is right under it.
I set both of them to [UIColor BlueColor], but at run time the outcome is that the nav bar has a slit darker color then the view.
Any knows what causes this?
Thanks
Your problem is that the navigation bar is translucent, and therefore the bar color is put on top of the view's color, making it appear darker. Try making the bar not translucent.
navigationBar.translucent = NO;
You can try this one:--
navigationController.navigationBar.barTintColor = [UIColor greenColor];
or
[[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];

Resources