Hide the UINavigationBar, but show the status bar

How to hide the navigation bar without hiding the status bar in my application? When I try [self.navigationController.navigationBar setHidden:YES]; , it also hides the status bar. I need to show the status bar as follows:

enter image description here

I need to hide the visible navigation bar first, make the status bar still visible, and I also have a view that I need to move below the status bar, but the view is positioned like the navigation bar still exists when I set the frame position to 0,0 .

I set my status bar as:

 [[UIApplication sharedApplication] setStatusBarHidden:NO]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
+7
ios xcode uinavigationcontroller
source share
3 answers

Add this to your code where you want to hide the navigation bar

[self.navigationController.navigationBar setHidden: YES];

+1
source share

If you want to hide the navigation bar, but display the status bar, you must set the Top space in the Layout Guide to 0 instead of -44. and then

Hide the navigation bar in viewWillAppear instead of viewDidLoad : [self.navigationController setNavigationBarHidden:YES animated:YES]

I start to set the top space as -44, then call the [[UIApplication sharedApplication] setStatusBarHidden:NO] method, it does not work.

0
source share

In my case, the status bar text and characters did not appear because they had the same color as the background (black). I solved the problem by changing the background color:

 [self.navigationController.navigationBar.superview setBackgroundColor:UIColor.whiteColor]; 
0
source share

All Articles