简体   繁体   English

状态栏与带有xcode5的iOS 7中的应用程序视图重叠

[英]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. 我将iPhone和xcode升级到iOS7和XCODE5。此后,我注意到的第一件事是状态栏与应用程序的查看区域重叠在一起。

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. 我通读了stackoverflow上发布的各种解决方案,例如将UIViewControllerBasedStatusBarAppearance的plist文件设置为NO,等等。似乎没有什么对我有用。 I have spent almost 4 days researching on it, but couldn't solve it. 我花了将近4天的时间对其进行研究,但无法解决。

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. 我现在想知道有一个类似于iOS 6的视图,其中我们在顶部显示黑色区域,或者完全摆脱状态栏,或者在iOS 7上执行此操作的确切方法是什么?

Any help would be greatly appreciated. 任何帮助将不胜感激。

Just set the view's y coordinate to 20. 只需将视图的y坐标设置为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.. 尝试将这段代码添加到每个Controller类的loadView中。

- (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.. 此代码解决了iOS-7上的问题。if条件确保在iOS-6及以下版本中将其忽略。

Put this code in your ViewController: 将此代码放在您的ViewController中:

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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