8

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];
SleepNot
  • 2,982
  • 10
  • 43
  • 72
  • did you set in your plist as viewcontroller based statusbar hidden yes – codercat Mar 18 '14 at 07:16
  • no it is UIViewControllerBasedStatusBarAppearance = NO; I also have: [[UIApplication sharedApplication] setStatusBarHidden:NO]; [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; – SleepNot Mar 18 '14 at 07:19
  • This link may help you to fix this issue - http://stackoverflow.com/questions/18915092/ios7-status-bar-hide-show-on-select-controllers – RAJA Mar 18 '14 at 07:54

3 Answers3

1

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

[self.navigationController.navigationBar setHidden:YES];

Rose
  • 437
  • 2
  • 9
  • Please check if you have correctly designed in your interface file. – Rose Mar 18 '14 at 10:54
  • 1
    I tried this but it also hides the status bar. What I want is to have atleast the effect in Facebook where when the navigationbar is hidden, the status bar still has a colored background. – SleepNot Mar 18 '14 at 10:59
  • Call [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent]; – Rose Mar 18 '14 at 11:02
0

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.

Community
  • 1
  • 1
Weiyi
  • 1,843
  • 2
  • 22
  • 34
0

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];
John
  • 8,468
  • 5
  • 36
  • 61