34

I'm trying to hide the status bar in iOS 4.3 now that setStatusBarHidden:animated: is deprecated:

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]; //deprecated

The only option that exists in the plist file is: Status bar is initially hidden. Which only hides the status bar at the start of the app.

Cheers

smileyborg
  • 30,197
  • 11
  • 60
  • 73
user346443
  • 4,672
  • 15
  • 57
  • 80
  • 2
    If the hidden/visible status doesn't change while the app is running, 'status bar is initially hidden' will do. I understand you need more flexibility but I thought some devs would be happy to know they can stick to the plist. –  Jun 14 '11 at 06:25
  • 1
    This worked for me: http://iphonedevelopertips.com/user-interface/gotcha-hiding-the-status-bar.html#comment-55017 gb – gonzobrains Jul 06 '11 at 18:06

5 Answers5

74

Try this:

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];

From Apple Class Reference:

setStatusBarHidden:withAnimation:

Hides or shows the status bar, optionally animating the transition. - (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation Parameters

hidden YES to hide the status bar, NO to show the status bar.

animation A constant that indicates whether there should be an animation and, if one is requested, whether it should fade the status bar in or out or whether it should slide the status bar in or out.

crimi
  • 875
  • 7
  • 8
  • and if i want to make a switch for the status bar ? how can i test the status (hidden or not) ? thanks – Fredv Jan 05 '13 at 13:04
8

But how about [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

See the UIApplication reference.

Till
  • 27,559
  • 13
  • 88
  • 122
4

The new method is:

- (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation

Works the same except the animation type is an enum now to support various animation types.

NWCoder
  • 5,296
  • 1
  • 26
  • 23
0
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
John Riselvato
  • 12,854
  • 5
  • 62
  • 89
Ashar
  • 217
  • 2
  • 13
0

seStatusBarHidden seems to be deprecated and not working anymore.

Use prefersStatusBarHidden on your view controller instead

- (BOOL)prefersStatusBarHidden
{
    return YES;
}
sobstel
  • 1,432
  • 16
  • 11