Search code examples
ios6ios7statusbaruiinterfaceorientationuiwindow

In iOS7, status bar default background is not rotating


I am developing an iPad application for iOS 6 and above. As we know for there is status bar view change. I have added below code to display normal status bar like iOS 6:

In AppDelegate.mm --> didFinishLaunchingWithOptions

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

    [application setStatusBarStyle:UIStatusBarStyleLightContent];

    self.window.clipsToBounds =YES;

    self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}

When I run my application over iOS 6, status bar looks fine for both the orientations. But when I run over iOS 7 simulator and device. Status bar does move with the rotation, but the black background of status bar is not moving at all.

Initial - Portrait: enter image description here

Rotate - Landscape: enter image description here

The same kind of issue comes for all three rotations, rather than Portrait.

Please guide me what could be the solution for this.


Solution

  • Instead of adding subview on UIWindow, set your viewcontroller as root view controller.

    AppDelegate.mm

    window.rootViewController = myViewController;
    // [window addSubview: myViewController.view];
    

    Hope this will help to others.