Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

enter image description here

How do I make the navigation bar opaque with a solid background color?

Thanks.

like image 314
s.d. Avatar asked Jan 21 '16 17:01

s.d.


People also ask

How do I make my navigation bar opaque?

Go to attribute inspector of for Navigation bar and remove check mark from translucent.

How do I change the background color of a navigation bar in Swift?

navigationController. navigationBar. barTintColor = UIColor. newBlueColor() and of course this just changes the colour of the navigation bar of the view controller that the code is within.


2 Answers

Go to attribute inspector of for Navigation bar and remove check mark from translucent.

Please find in image.

enter image description here

like image 182
technerd Avatar answered Sep 20 '22 21:09

technerd


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.

enter image description here

like image 34
Maihan Nijat Avatar answered Sep 18 '22 21:09

Maihan Nijat