This is just a quick tip with some basic logic on how to get a colored status bar on an iphone app ,here i will be assuming that the app does not rotate so i will be placing all the code in appdelegate in the
So the secret is really that there is no secret ,apples framework does not allow you to choose the color of the status bar so instead we set the status bar to the translucent predefined style of UIStatusBarStyleBlackTranslucent and then we draw a colored view behind it to make it appear as though the color of the bar has changed. Here is a sample where i "tinted" the statusbar cyan in the app delegate :
Again this only works if your app does not rotate , though it wont take much modification to support that,the main thing here is that you need to understand that to color the statusbar you have to make it transparent and draw behind it. This is what your app should look like if you were to place this code snippet into your appdelegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
So the secret is really that there is no secret ,apples framework does not allow you to choose the color of the status bar so instead we set the status bar to the translucent predefined style of UIStatusBarStyleBlackTranslucent and then we draw a colored view behind it to make it appear as though the color of the bar has changed. Here is a sample where i "tinted" the statusbar cyan in the app delegate :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
UIView *colorStatBar = [[UIView alloc] initWithFrame:CGRectMake(0,0,320 , 20)];
colorStatBar.backgroundColor = [UIColor cyanColor];
colorStatBar.bounds = CGRectMake(0,0, 320, 20);
[_window addSubview:colorStatBar];
return YES;
}
Comments
Post a Comment