5

iOS 6 look...

enter image description here

Same way i would like to display status bar in iOS 7 like

see this

enter image description here

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,,,

Anindya Sengupta
  • 2,539
  • 2
  • 21
  • 27
SWT
  • 531
  • 2
  • 5
  • 16

3 Answers3

17

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);
    }
}
Stanislav
  • 410
  • 3
  • 11
  • my apps run in Landscape mode. but your code appear black bar right and left side – SWT Oct 04 '13 at 09:03
  • Updated an answer to support both orientations. – Stanislav Oct 04 '13 at 10:04
  • but working fine... but when i rotate screen that was not changing based on screen orientation – SWT Oct 04 '13 at 11:18
  • 8
    You 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. – Stanislav Oct 04 '13 at 12:06
  • actually the key you have to add to info.plist is: UIViewControllerBasedStatusBarAppearance = NO – mindbomb Apr 21 '14 at 18:20
9

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)];
Shams Ahmed
  • 4,498
  • 4
  • 21
  • 27
Eric Sanchez
  • 1,111
  • 1
  • 9
  • 8
0

Move your frame 20 pixels down. You can try writing this in your ViewWillappear or DidAppear

CGRect frame = self.view.frame;
frame.origin.y = 20;

if (self.view.frame.size.height == 1024 ||   self.view.frame.size.height == 768)
{
    frame.size.height -= 20;
}
self.view.frame = frame;  

Now set background color of window to black in applicationDidFinishLaunching and set statusbar font to be white (StatusBarContentLight)

Remember what i am suggesting is not perfect solution but a fix that will work nicely. Also use same code when app changes its orientation (ShouldAutorotate)

Bhumit Mehta
  • 16,278
  • 11
  • 50
  • 64