Navigation bar background color - translucency is no
10,888
Solution 1
Use this line of code in your viewController didLoad method
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:29.0f/255.0f green:149.0f/255.0f blue:174.0f/255.0f alpha:1.0f]
Solution 2
Use this one,
self.navigationController.navigationBar.tintColor=[UIColor colorWithRed:19.0/255.0f green:52.0/255.0f blue:36.0/255.0f alpha:1];
Author by
Lord Zsolt
Updated on June 04, 2022Comments
-
Lord Zsolt almost 2 years
I would like to change the background color of the navigation bar to a solid green.
Rule: I can't mess with the AppDelegate :)
I've tried:
//It's green but it's translucent [self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; //It's white, first line has no effect [self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; [self.navigationController.navigationBar setTranslucent:NO]; //Same result as case 1 [self.navigationController.navigationBar setAlpha:0.0f]; [self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; //Too dark [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackTranslucent]; [self.navigationController.navigationBar setBackgroundColor:[UIColor colorWithRed:77/255.0 green:255/255.0 blue:100/255.0 alpha:1.0f]]; //Only affects the back button's color: [self.navigationController.navigationBar setTintColor:[UIColor greenColor]];
So any ideas?
Thank you, didn't see there was barTintColor and TintColor as well. Accepting earliest answer.