Reputation: 4908
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
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
}
viewDidLoad
doing if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Great.
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?
Upvotes: 3
Views: 4266
Reputation: 1524
I came up with the similar problem. To fix it, you don't have to disable View controller-based status bar
In UITabBarController
class, set extended layout to UIRectEdgeNone
self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;
Then set navigationBar.barTintColor
some where else.
setting edgesForExtendedLayout
in child view controller does not work.
Upvotes: 2
Reputation: 4908
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!
Upvotes: 3