【发布时间】:2018-02-24 14:58:07
【问题描述】:
我在应用程序窗口中添加了导航栏,但导航栏与状态栏发生冲突。 (我需要用应用程序窗口来做)。
我试过的代码是:
UIWindow * firstWindow = [UIApplication sharedApplication].windows[0];
UINavigationBar * navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, firstWindow.frame.size.width, 64)];
/*
// I tried these also
UINavigationBar * navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, firstWindow.frame.size.width, 84)];
UINavigationBar * navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, firstWindow.frame.size.width, 64)];
*/
[firstWindow addSubview:navBar];
结果如下:
我环顾四周并尝试了与默认导航栏相关的所有答案,但没有任何效果:
What is the height of Navigation Bar in iOS 7?
iOS 10 custom navigation bar height
iOS 7 status and navigation bar different height in storyboard than in app
UINavigationBar/Status Bar issue in IOS7
When hiding the statusbar my navigation bar moves up in iOS7
iOS 7 Status Bar Collides With NavigationBar using ViewController
【问题讨论】:
-
为什么需要在主窗口中添加
UINavigationBar? -
我需要在所有视图、屏幕和窗口之上执行一些与应用程序安全相关的操作(身份验证),以防止用户访问。我的应用程序中很少有代码已经在使用顶级(根)视图控制器及其窗口进行其他操作。
-
您需要像第一张图片中一样的导航栏吗?我的意思是状态栏背景颜色为蓝色?
-
84 高会怎样?
-
它没有变为 84。它仍然是 44..
标签: ios objective-c statusbar xcode9 navigationbar