Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationBar hides under statusBar [duplicate]

In some UIViewController, UINavigationBar hides under status bar. Here is the screenshot:

<code>UINavigationBar</code> under StatusBar

But when I change View controller-based status bar appearance to YES then UINavigationBar looks perfect. Here is the screenshot:

black text in <code>UIStatusBar</code>

But in this case, textColor of status bar goes change from white to black. I want white text color of status bar and also unhide UINavigationBar from status bar. Is there any way to solve out it (White color of status bar and unhide UINavigationBar).

Thanks in advance!

like image 646
Sudha Tiwari Avatar asked Oct 18 '22 07:10

Sudha Tiwari


2 Answers

You can always manually set the origin of the navigation bar in viewWillAppear(animated: Bool)

self.navigationController?.navigationBar.frame.origin = CGPoint(0, 20)
like image 121
Zach P Avatar answered Oct 21 '22 04:10

Zach P


Add these keys to your project Info.plist and you should be ok.

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
like image 30
吴山山 Avatar answered Oct 21 '22 06:10

吴山山