The Status Bar (or UIStatusBar) is the 20-pixel-high strip at the top of the window that shows the carrier name and signal strength, network status, current time, and battery strength:
Default | |
---|---|
Black Opaque | |
Black Translucent |
The status bar can be gradient gray (with black text), black opaque (with white text), or black translucent. By default the status bar is gray. If your app features standard iPhone UI elements, then stick with the default status bar. However if your app has custom views with dark backgrounds, then a black status bar will look better.
Black and white status bars push the underlying views down, giving you 320 x 460 pixels of screen space to work with in your app. A translucent status bar overlays the underlying view, giving you the full 320 x 480 pixels of screen space. (More on sizes)
You can set the status bar style either programmatically or in your Info.plist file. If you change it in Info.plist, then the style is changed when the app launches (while the app is loading). If you change it programmatically, then the style changes after the app finishes loading.
To change the status bar style in Info.plist, look for your Appname-Info.plist file in the Resources group of your Xcode project. To add a new element to this file, click on the last line of options so that the + symbol appears on the right. Click it, then enter UIStatusBarStyle in the left column. After you set that, the right column will then change to a list of options:
To change the style programmatically after the app has launched, add this line to your app delegate's applicationDidFinishLaunching method:
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
Valid status bar styles are UIStatusBarStyleDefault, UIStatusBarStyleBlackTranslucent, and UIStatusBarStyleBlackOpaque.
Hiding the Status Bar
You can also hide the status bar completely, but give some consideration as to whether you should do this. From the iPhone Human Interface Guidelines: "People expect to be able to see the current battery charge of their devices; hiding this information, and requiring users to quit your application to get it, is not an ideal user experience."
To hide the status bar when the app launches, add a new line to Info.plist and enter UIStatusBarHidden in the left column. The right column will change to a checkbox:
To hide the status bar after the app has completely launched, change it programmatically by adding this line to your app delegate's applicationDidFinishLaunching method:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
If you set animated to YES then the status bar will disappear by fading out.
No comments:
Post a Comment