8
votes

How can I hide the navigation bar by not hiding the status bar in my app? When I try [self.navigationController.navigationBar setHidden:YES]; it also hides the status bar. I need to show the status bar like this:

enter image description here

I need to first hide a visible navigation bar, 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 being positioned like the navigation bar is still there when I set the frame's position to 0,0.

I setup my statusbar as:

[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
3
did you set in your plist as viewcontroller based statusbar hidden yescodercat
no it is UIViewControllerBasedStatusBarAppearance = NO; I also have: [[UIApplication sharedApplication] setStatusBarHidden:NO]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];SleepNot
This link may help you to fix this issue - stackoverflow.com/questions/18915092/…RAJA

3 Answers

1
votes

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

[self.navigationController.navigationBar setHidden:YES];

0
votes

If you want to hide navigation bar but show status bar, you should set Top Space to Top Layout Guide as 0 instead of -44. and then

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

I start to set top space as -44, then call method [[UIApplication sharedApplication] setStatusBarHidden:NO], it doesn't work.

0
votes

In my case, the status bar text and symbols were not shown 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];