Set Status Bar Color and Background

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

UIApplication Class
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];
  1. Thank you for the post. If I can specify something, the difference beween using info.plist and coding in application delegate is that ApplicationDidFinishLaunshing is called once all application launching stuff has been done. Therefore, if you put some core related to statusbar here, it will have an effect almost one second after launching of your app. On the other hand, if you use the info.plist, you can see it as a direct access to UIApplication singleton instance itself, and therefore this setting will apply instantaneously.

    So I would recommend using info.plist whenever it is possible and application delegate only when you don’t have the choice.

  2. Thanks! Very helpful! This is just what I needed to know.

Comments are closed.