How to set Status bar background color iOS 7
52,840
Solution 1
You have to do 2 things. First is to open your info.plist
and set "View controller-based status bar appearance" = NO
And the second is to add this lines to application:didFinishLaunchingWithOptions
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
self.window.clipsToBounds = YES;
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
self.window.frame = CGRectMake(20, 0,self.window.frame.size.width-20,self.window.frame.size.height);
self.window.bounds = CGRectMake(20, 0, self.window.frame.size.width, self.window.frame.size.height);
} else
{
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
}
}
Solution 2
Read this article: http://www.appcoda.com/customize-navigation-status-bar-ios-7/
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
[[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];
Comments
-
SWT almost 2 years
iOS 6 look...
Same way i would like to display status bar in iOS 7 like
see this
but My actual output (Overlap)
i have tried following logic
open your info.plist and set "View controller-based status bar appearance" = NO
it's not working in my code,,,
-
SWT over 10 yearsmy apps run in Landscape mode. but your code appear black bar right and left side
-
Stanislav over 10 yearsUpdated an answer to support both orientations.
-
SWT over 10 yearsbut working fine... but when i rotate screen that was not changing based on screen orientation
-
Stanislav over 10 yearsYou should register for statusbarorientationchanged notification and use the same code over there. I can not write the app instead of you, I already gave you an answer, so you should get it's point and use it accordingly to your needs.
-
capikaw over 10 yearsExcellent link for those devs putting images on their UINavigationBar.
-
cynistersix over 10 yearsSadly didn't do much for my iPad application. Good link though
-
mindbomb about 10 yearsactually the key you have to add to info.plist is: UIViewControllerBasedStatusBarAppearance = NO
-
Fraggle over 9 yearsFor some reason this isn't working for me, storyboard, ios7. Added that line to AppDelegate didFinishLaunching