1

my status bar appearance before picking an image

Iam using status bar in my application and i wriiten the code in the following manner

my status bar position after picking image

My project includes tab bar controller. So, after picking an image from library my status bar is changing its postion. How can it solved?

please Anybody help on this I wasted Lot of time With this.

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(0, 0,self.window.frame.size.width-20,self.window.frame.size.height);
        self.window.bounds = CGRectMake(0, 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);
        self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
    }
}

Thanks in Advance.

3 Answers3

1

Try this:

The key in info.plist file :

'View controller-based status bar appearance' and set to NO.

Also in appDelegate.

[application setStatusBarHidden:NO]; 
[application setStatusBarStyle:UIStatusBarStyleDefault];  // change style as per your requirement
Mrunal
  • 13,982
  • 6
  • 52
  • 96
  • Generally it is right what u said, but the thing is different here bcz iam using tabbar controller with navigation bar,so i need to update the frame of tab bar & navigation bar. can u help on this? – Rakesh Kumar Dec 31 '14 at 08:09
  • Then you can do the same with tabbarcontroller.view.frame and for each viewcontroller - viewcontroller.navigationcontroller.navigationbar.frame – Mrunal Dec 31 '14 at 09:44
0

In iOS7 and above the status bar is transparent so the best way of achieving this is to make a base controller and extend every controller from it and in viewDidLoad of base controller just create a singleton object of that view (i.e. black view) with frame CGRectMake(0, 0, view.frame.size.width, view.frame.size.height) with auto resizing mask with width and add it as a subview.

Adeel Ur Rehman
  • 616
  • 5
  • 14
-1
(void)layoutSubviews {
    self.frame = CGRectMake(0, 0, 320, 64);
}
Anthon
  • 69,918
  • 32
  • 186
  • 246