Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 status bar issues with UITabBarController

Tags:

ios

iphone

Yes, I have seen many questions about this, but nothing that deals with my specific problem.

I have managed to get the status bar to be a solid black (I'd like blue but I am happy that it is solid an not transparent). I accomplished this by doing

  1. in MyApp-Info.plist adding the 'View controller-based status bar appearance' = NO value
  2. In the AppDelegate doing if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { [application setStatusBarStyle:UIStatusBarStyleLightContent]; self.window.clipsToBounds =YES; }
  3. in my viewDidLoad doing if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) { self.edgesForExtendedLayout = UIRectEdgeNone; }

Great.

enter image description here

But behind a UITabBarController it is still transparent. The view controllers inside my tabbarcontroller are subclasses of a the same view controller in the first screen shot. And the same viewDidLoad code is being called.

Any ideas?

enter image description here

like image 690
phil Avatar asked Nov 27 '25 06:11

phil


1 Answers

After several days of messing around I have a solution:

1) set View controller-based status bar appearance to NO in the MyApp-info.plist (add the key if you need it)

2) Put this in the master and detail view controllers viewDidLoad:

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.barTintColor = [your background colour];
self.navigationController.navigationBar.tintColor = [color of the text of buttons];

3) This will make the top bar opaque, so, in the storyboard, if you have a uitabbarcontroller you need to set the under opaque bars setting on it.

As a bonus tip: To make the navigation bar match it I do the following in the AppDelegate didFinishLaunchingWithOptions:

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc]init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:[same color as barTintColor above]];
[[UINavigationBar appearance] setTitleTextAttributes:@{UITextAttributeTextColor:[UIColor whiteColor]}];

I hope this helps someone!

like image 107
phil Avatar answered Nov 28 '25 20:11

phil