Thursday, 20 March 2014

iPhone Developemnt: Set statusbar color to light content





Every phone has status bar that tells user about status of some of major parts of the phone, like battery, signal strength, running internet or not. Like other phone's, iPhone also has status bar.


As you can see in the picture, status bar in iPhone is shown on top of the phone screen. see picture to left of your screen the one on top of the image where carrier is written.
With the introduction of IOS 7, app developer can change status-bar color based on their screen background. If the background is dark color then they can show white color status bar, as shown in the picture.

This feature is called UIStatusBarStyleLightContent, and as per its description it says
UIStatusBarStyleLightContent:A light status bar, intended for use on dark backgrounds.

We can enable our app to use this feature by following steps
Go to your info.plist file and add two properties to it (if not added)
1. view-controller based status bar appearence
2. status bar is initially hidden
Set both of these to NO.
Both of these are shown below in the picture for better clarification



Now, select your AppDelegate.m file and go to - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method
In this method set your statusbar style to UIStatusBarStyleLightContent

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];

This will show status bar in white color on your dark background screens.



No comments:
Write comments