2013-11-26 88 views
1

我在應用程序中通過代碼添加了導航控制器。所有其他的事情工作正常,但我的導航欄與狀態欄重疊。我嘗試加入狀態欄與導航欄重疊

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) 
    self.edgesForExtendedLayout = UIRectEdgeNone; 

但它不工作。

我在導航控制器中的其他控制器只在xibs中不是故事板。 請幫忙。

回答

1

我解決了用下面的代碼的問題(如suggested by Tacettin Özbölük):

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { 
    UIView *addStatusBar = [[UIView alloc] init]; 
    addStatusBar.frame = CGRectMake(0, 0, 320, 20); 
    addStatusBar.backgroundColor = [UIColor colorWithRed:0.973 green:0.973 blue:0.973 alpha:1]; //change this to match your navigation bar 
    [self.window.rootViewController.view addSubview:addStatusBar]; 
} 
1

如果你真的不想要你的導航欄是半透明的,然後使用此代碼,您的問題將得到解決:

self.navigationController.navigationBar.translucent = NO;