How to Remove Status Bar in "View Based Application" - iOS

14,270

If you read the "header" you will see "Simulated metrics". Those properties are only to simulate visual elements when you lay out your code with interfacebuilder.

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

If you do it in the Application Delegate you write:

    [application setStatusBarHidden:YES animated:NO];

in this method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {...}

EDIT

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/setStatusBarHidden:withAnimation:

Requested in comment, from documentation:

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.

Discussion

See the descriptions of the constants of the UIStatusBarAnimation type for more information. Availability

* Available in iOS 3.2 and later.

So if you are not interested in the animation part I suggest using this:

statusBarHidden

A Boolean value that determines whether the status bar is hidden. @property(nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden Return Value

YES means the status bar is hidden; NO means it's visible. Availability

* Available in iOS 2.0 and later.
Share:
14,270

Related videos on Youtube

Ohad Regev
Author by

Ohad Regev

iPhone/iPad apps developer

Updated on June 04, 2022

Comments

  • Ohad Regev
    Ohad Regev almost 2 years

    This is a part of me trying to get used to working with XCode4...

    OK, so i've created a new project in XCode 4 and I used the View Based Application template; I wish to build the new app as Apple intended me to use this template.

    So I'm using the automatically-created-view-controller which is called from the AppDelegate (so far I haven't touched anything). Now, I want to remove the STATUS BAR. As far as I understand, what I should do, is go to the view XIB and in the Attributes Inspector set the Status Bar field to None (this is how I used to do it so far), but mercilessly when I run the application the STATUS BAR is still there (!).

    I also tried to do the same thing on the mainWindow.xib file (the setting the STSTUS BAR attribute to None thing) and the app runs with this bar that blocks my view...

    Anyone?

    enter image description here

  • Ohad Regev
    Ohad Regev almost 13 years
    thanks Andreas, it did hide the status bar (I used the second option you suggested); but I get a warning --- Deprecations: 'setStatusBarHidden:animated:' is deprecated --- any idea what it may be?
  • LuckyLuke
    LuckyLuke almost 13 years
    @Ohad: No problem, did not know that it was deprecated, I have updated the answer for you.