[英]status bar overlaps with navigation bar
I am adding navigation controller through code, in my application. 我正在通过代码在应用程序中添加导航控制器。 All other thing work fine, but my navigation bar overlaps with the status bar.I have tried by adding
其他所有东西都可以正常工作,但是我的导航栏与状态栏重叠。我尝试通过添加
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
but it is not working. 但它不起作用。
My other controllers in that navigation controller are in xibs only not storyboard. 该导航控制器中的其他控制器仅位于xib中,而不是情节提要中。 Please help.
请帮忙。
I solved the problem with the following code (as suggested by Tacettin Özbölük ): 我使用以下代码(如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];
}
如果您确实不希望导航栏是半透明的,那么使用此代码,您的问题将得到解决:
self.navigationController.navigationBar.translucent = NO;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.