0

I upgraded my iPhone and xcode to iOS7 and XCODE 5. After this, the first thing i noticed was that the status bar over laps with the app's view area.

I read through various solutions posted on stackoverflow, like setting the plist file with UIViewControllerBasedStatusBarAppearance to NO, etc. Nothing seems to be working for me. I have spent almost 4 days researching on it, but couldn't solve it.

I want to know now to have a iOS 6 like view where we have a black area displayed on top or get rid of the status bar altogether or what is the exact way of doing it on iOS 7.

Any help would be greatly appreciated.

  • possible duplicate of [iOS 7 status bar back to iOS 6 style?](http://stackoverflow.com/questions/18294872/ios-7-status-bar-back-to-ios-6-style) – jaredsinclair Oct 03 '13 at 01:55

3 Answers3

1

Just set the view's y coordinate to 20.

CGRect frame = [self.view frame];
frame.origin.y = 20;
[self.view setFrame:frame];

I have not tested this but it might work:

UIView *statusBarBack = [[UIView alloc] initWithFrame:CGRectMake(0, -20, 320, 20)];
[statusBarBack setBackgroundColor:[UIColor blackColor]];
[self.view addSubview:statusBarBack];
carloabelli
  • 4,289
  • 3
  • 43
  • 70
  • Hi Cabellicar123, Thanks for the response. I tried to add the code in the viewDidLoad method of my view controller as below: CGRect frame = [self.view frame]; frame.origin.x = 20; [self.view setFrame:frame]; It didn't work :( – Ranjit Alexander Oct 02 '13 at 23:55
  • @RanjitAlexander Did the view move down? Also did you add a second view behind the status bar? I will add the code necessary to the answer. – carloabelli Oct 03 '13 at 01:41
  • @RanjitAlexander Also you put x but make sure it is y. I miss typed it in the description. Sorry. – carloabelli Oct 03 '13 at 01:54
1

Try adding this piece of code in loadView of every Controller class..

- (void)loadView {
    [super loadView];
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = YES;
    }

    // Rest of your code...
}

This Code fixes the issue on iOS-7.. The if condition ensures it is ignored in iOS-6 and below..

Roshit
  • 1,589
  • 1
  • 15
  • 37
  • Thank you for the response. I added the piece of code in my controller.m file. But, the status bar still shows up on the view area. I debugged to see if the code is getting executed, it does. But I couldn't see any change from the way it displayed before the code was added. :(( – Ranjit Alexander Oct 03 '13 at 00:51
0

Put this code in your ViewController:

-(BOOL)prefersStatusBarHidden
{
    return YES;
}
Bram
  • 7,440
  • 3
  • 52
  • 94