1

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?

2
  • 1
    is your implementation for colorWithHex: correct? Because that's not a UIKit method.. Also, try using a breakpoint to confirm that you are actually implementing the subclass.. Commented Jan 17, 2016 at 22:24
  • is the method colorWIthHex called ? You shouldn't use navigationCOntroller reference in a NAvigationController subclass Commented Jan 17, 2016 at 23:23

3 Answers 3

2

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; } 
Sign up to request clarification or add additional context in comments.

Comments

0

Please try this:

- (void)viewDidLoad { [super viewDidLoad]; [self.navigationBar setBarTintColor:[UIColor redColor]]; } 

Make sure you set UINavigationController class to your's custom controller.

enter image description here

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.