user717452
user717452

Reputation: 111

UINavigationBar appearance setBackgroundImage Hides Status Bar

UIImage *gradientImage46 = [[UIImage imageNamed:@"navbar.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];


 [UINavigationBar appearance] setBackgroundImage:gradientImage46
                                           forBarMetrics:UIBarMetricsDefault];

I am using this to customize the appearance of my navigation bars in my app. However, this is causing the status bar to be solid black, showing nothing...time, carrier, battery, etc. Is this a bug, or did I implement this incorrect?

I have this running in a tab bar using MainWindow.xib method for interface. The first tab is just a navigation controller with a view controller inside it. Another tab is a Navigation Controller with a TableView Controller inside. If I go from one tab to the table view, and then back, the status bar appears.

The navbar.png is 320 x 44 pixels.

Upvotes: 2

Views: 1176

Answers (1)

Ilario
Ilario

Reputation: 6079

I also have this problem bringing my app from iOS 6 to iOS7, I solved by changing the code in this way:

instead

[UINavigationBar appearance] setBackgroundImage:gradientImage46
                                       forBarMetrics:UIBarMetricsDefault];

i use

-(void) viewWillAppear:(BOOL)animated {

  [self.navigationController.navigationBar setBackgroundImage:gradientImage46 forBarMetrics:UIBarMetricsDefault];
}

Upvotes: 3

Related Questions