How to hide the title bar in the iPhone main windo

2020-08-19 18:01发布

问题:

This question might be very easy to answer so I apologize if I missed the obvious. I'm developing a GUI application on the iPhone and want to hide the title/status bar of the iPhone which usually displays the carrier/time/battery. How can I do this from within the code given the main UIWindow and UIView?

-A

回答1:

In your Info.plist file, set UIStatusBarHidden to true or add the following to your application delegate:

[[UIApplication sharedApplication] setStatusBarHidden:YES];


回答2:

The answers above are deprecated. The right way to do this programmatically is now:

[[UIApplication sharedApplication] setStatusBarHidden:YES 
                                   withAnimation:UIStatusBarAnimationNone] ;

If you want you could use UIStatusBarAnimationFade or UIStatusBarAnimationSlide instead of UIStatusBarAnimationNone



回答3:

prefersStatusBarHidden

Specifies whether the view controller prefers the status bar to be hidden or shown.

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

UIViewController Class Reference

https://developer.apple.com/library/ios/Documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/prefersStatusBarHidden



回答4:

As at writing of this replies, Xcode 4.1, just use the following:

[[UIApplication sharedApplication] setStatusBarHidden:TRUE];

will not have white space at the top.

alternatively, the plist entry is:

"Status bar is initially hidden"



标签: iphone