ary*_*axt 109 statusbar ios ios7
我有一个ViewController在里面UINavigationcontroller,但导航栏是隐藏的.当我在iOS 7上运行应用程序时,状态栏显示在我的视图之上.有办法避免这种情况吗?
我不想编写任何特定于操作系统的代码.

我试着设置View controller-based status bar appearance到NO,但它并没有解决这个问题.
ary*_*axt 95
Xcode 5 iOS 6/7 Deltas专门用于解决此问题.在故事板中,我将我的视图向下移动了20个像素,在iOS 7上向右看,为了使其与iOS 6兼容,我更改Delta y为-20.

由于我的故事板没有使用自动布局,为了在iOS 6上正确调整视图的高度,我必须设置Delta height为Delta Y.
Nat*_*n H 69
如果您根本不想要任何状态栏,则需要使用以下数据更新plist:要在plist中执行此操作,请添加以下两个设置:
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Run Code Online (Sandbox Code Playgroud)
在iOS 7中,您需要设计一个覆盖透明状态栏的应用程序.例如,请参阅新的iOS 7天气应用程序.
Vin*_*ent 43
这是UIViewControlleriOS 7上的默认行为.视图将全屏显示,这意味着状态栏将覆盖视图的顶部.
如果你有一个UIViewController内部的UINavigationController和的导航栏是可见的,你可以有下面的代码在你的viewDidLoad或有背景图片的导航栏做的伎俩.
self.edgesForExtendedLayout = UIRectEdgeNone;
Run Code Online (Sandbox Code Playgroud)
如果您隐藏了navigationBar,则必须通过移动20个点来调整所有UIView元素.我没有看到任何其他解决方案.使用自动布局会有所帮助.
以下是用于检测iOS版本的示例代码,如果您想要向后兼容.
NSUInteger DeviceSystemMajorVersion() {
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *systemVersion = [UIDevice currentDevice].systemVersion;
_deviceSystemMajorVersion = [[systemVersion componentsSeparatedByString:@"."][0] intValue];
});
return _deviceSystemMajorVersion;
}
Run Code Online (Sandbox Code Playgroud)
com*_*tos 15
只有我自己做的工作解决方案.
这是我的UIViewController子类https://github.com/comonitos/ios7_overlaping
来自UIViewController的1个子类
2从该类中对window.rootViewController进行子类化.
3瞧!
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
CGRect screen = [[UIScreen mainScreen] bounds];
if (self.navigationController) {
CGRect frame = self.navigationController.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.navigationController.view.frame = frame;
} else {
if ([self respondsToSelector: @selector(containerView)]) {
UIView *containerView = (UIView *)[self performSelector: @selector(containerView)];
CGRect frame = containerView.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
containerView.frame = frame;
} else {
CGRect frame = self.view.frame;
frame.origin.y = 20;
frame.size.height = screen.size.height - 20;
self.view.frame = frame;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
4添加此项以使状态栏变为白色就在[self.window makeKeyAndVisible]之后; !
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
Run Code Online (Sandbox Code Playgroud)
Dar*_*hah 13
-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
-(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 viewFrame1 = [self.view convertRect:self.view.frame toView:nil];
if (!CGRectEqualToRect(screenFrame, viewFrame1))
{
self.view.frame = screenFrame;
self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在plist中添加键---查看基于控制器的状态栏外观:NO
| 归档时间: |
|
| 查看次数: |
109301 次 |
| 最近记录: |