2013-10-12 76 views
2

我在状态栏问题7

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; 

    RootViewController *rvc = [[[RootViewController alloc] init] autorelease]; 
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:rvc] autorelease]; 

    self.window.rootViewController = navController; 
    [self.window makeKeyAndVisible]; 
    return YES; 

} 

View controller-based status bar appearance is YES in plist file 

,当我推视图控制器状态栏寻找伟大返回。如下图所示。

enter image description here

,但是当我提出modelviewcontroller它看起来如下。

enter image description here

我已经在视图控制器的viewDidLoad方法其中我提出

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { 
    // iOS 7 
    navBar.frame = CGRectMake(navBar.frame.origin.x, 20, navBar.frame.size.width, 44); 
} 

我想在presentingmodelview以显示黑色的状态栏写下面的代码。但它没有显示。 我试过

基于视图控制器的状态栏外观也不在plist文件 中,但它不起作用。

我的代码在7.0以下的所有ios版本中运行良好,但在ios 7.0及更高版本中不能运行。

任何解决方案?如果有人没有收到我的问题,请告诉我。

+0

在iOS 7默认状态栏是透明的。 –

+0

所以你必须采取与高度20 UIImageview并设置背景颜色黑色。并在尺寸检查器中将其设置为增量值-20 –

回答

4

this question中找到了很好的解决方案。

1)设置到UIViewControllerBasedStatusBarAppearance NO在info.plist中(要停用具有视图控制器调整状态栏样式,使我们可以通过使用UIApplicationstatusBarStyle方法设置状态栏风格。)

2)在AppDelegate的应用程序:didFinishLaunchingWithOptions,请致电

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

    self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height); 
} 
return YES;