简体   繁体   中英

status bar overlaps with the app view in iOS 7 with xcode5

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.

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];

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

Put this code in your ViewController:

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM