Reputation: 39
I added the Navigation View Controller
in storyboard and connected it to each ViewController
.
I then created the class:
@interface NavigationViewController : UINavigationController
In the implementation I have the following code:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithHex:@"#F40116" alpha:1.0];
self.navigationController.navigationBar.translucent = NO;
}
I tried to change background for navigationBar
to Red in all ViewControllers - but background is still white. How can I make them all Red?
Upvotes: 1
Views: 464
Reputation: 443
I guess you are trying to change the color of the navigationBar of the navigationController of your navigationController.
Try this:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationBar.barTintColor = [UIColor colorWithHex:@"#F40116" alpha:1.0];
self.navigationBar.translucent = NO;
}
Upvotes: 2
Reputation: 736
Try to make all visual changes on viewWillAppear
- (void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.navigationBar.tintColor = [UIColor redColor];
}
this should work for you.
Upvotes: 0
Reputation: 391
Please try this:
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationBar setBarTintColor:[UIColor redColor]];
}
Make sure you set UINavigationController
class to your's custom controller.
Upvotes: 0