Okay, so the title of the post is a little misleading. You only have two color choices for the status bar, UIStatusBarStyleDefault (gray) and UIStatusBarStyleBlackOpaque (black).
However, there is a status bar style that offers a range of flexibility to set a color or background image. Read on…
The default status bar style/color is shown below:
Changing the style to opaque looks as follows:
The third option, which provides an opportunity to customize the look of the status bar, is the UIStatusBarStyleBlackTranslucent style. In the figure below, I set the background image to the top leftmost corner and set the status bar style to translucent, which allows the image to show through.
The same logic would apply if you want to have a status bar with a specific color. For example, below I set the background color to [UIColor redColor]. Notice you don’t get an uber red status bar in this case, however, using the seemingly endless variations of colors, you can generally come pretty close to whatever you need.
So how do we make this stuff happen? There are two options, specify your preferences in Info.plist or use the UIApplication class.
Add one of the following settings in the Info.plist file:
– UIStatusBarStyle UIStatusBarStyleBlackTranslucent
– UIStatusBarStyle UIStatusBarStyleBlackOpaque
– UIStatusBarStyle UIStatusBarStyleDefault
Set one of the following inside the app delegate:
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO]; - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO];