【发布时间】:2014-11-05 00:46:10
【问题描述】:
我正在开发一个在 IOS6 中运行良好的应用程序。但在iOS7中,状态栏与视图重叠。
例如:
我首先需要状态栏,然后我的图标和删除最后。所以请告诉我有关如何删除重叠的任何想法。
但我需要这个
请告诉我有关我的问题的任何想法
【问题讨论】:
标签: ios objective-c ios7 ios6 statusbar
我正在开发一个在 IOS6 中运行良好的应用程序。但在iOS7中,状态栏与视图重叠。
例如:
我首先需要状态栏,然后我的图标和删除最后。所以请告诉我有关如何删除重叠的任何想法。
但我需要这个
请告诉我有关我的问题的任何想法
【问题讨论】:
标签: ios objective-c ios7 ios6 statusbar
Xcode 具有专门用于解决此问题的 iOS 6/7 Deltas。您必须将视图向下移动 20 像素才能在 iOS 7 上看起来正确,为了使其与 iOS 6 兼容,您将 Delta y 更改为 -20。
在 iOS 6 上正确调整视图的高度您必须设置 Delta 高度以及 Delta Y。
你也可以看到这个 - Fix iOS 7 Status bar overlapping
【讨论】:
-(void)viewWillLayoutSubviews{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
self.view.clipsToBounds = YES;
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenHeight = 0.0;
if(UIDeviceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]))
screenHeight = screenRect.size.height;
else
screenHeight = screenRect.size.width;
CGRect screenFrame = CGRectMake(0, 20, self.view.frame.size.width,screenHeight-20);
CGRect viewFr = [self.view convertRect:self.view.frame toView:nil];
if (!CGRectEqualToRect(screenFrame, viewFr))
{
self.view.frame = screenFrame;
self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
}
}
【讨论】:
试试这个代码。在你的 AppDelegate.m 中使用这个代码来完成启动:
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);
}
【讨论】:
这是 iOS 7 上 UIViewController 的默认行为。视图将是全屏的,状态栏将覆盖视图的顶部。如果你隐藏了导航栏,那么你必须通过移动 20 个点来调整所有 UIView 元素。
【讨论】: