The top bar color change when we change of view

I have a problem with my top bar, i initialize a color in my MainViewController with a function that is used in the viewDidLoad :

UIColor *barColour = [UIColor colorWithRed:22.0f/255.0f green:61.0f/255.0f blue:121.0f/255.0f alpha:1.0f];
UIView *colourView = [[UIView alloc] initWithFrame:CGRectMake(0.f, -20.f, 320.f, 64.f)];
colourView.opaque = NO;
colourView.alpha = .7f;
//colourView.backgroundColor = barColour;
self.navigationController.navigationBar.barTintColor = barColour;
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar.layer insertSublayer:colourView.layer atIndex:1];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont
                                                                       fontWithName:@"Helvetica Neue" size:20], NSFontAttributeName,
                            [UIColor whiteColor], NSForegroundColorAttributeName, nil];

self.navigationController.navigationBar.titleTextAttributes = attributes;

But when i change of view, the top bar became gray and when i click on return the MainViewController top bar became gray too. Have an idea for why it became gray ? And how correct that ?


Call this _initCustomTopBar in your viewWillAppear method


[self _initCustomTopBar];


Need Your Help

How does the messages-count example in Meteor docs work?

javascript mongodb meteor publish-subscribe

Having trouble full understanding this example from the docs... I tried running it a bunch of different ways so I could observe how it works, etc.

How to group by one field and sort by another field with Crystal Report

sorting crystal-reports

I would like to group by one field and sort by another field with Crystal Report.