Status bar

April 28th, 2009 by Chris Leave a reply »

Status bar is a tiny rectangle ( 320 x 20 px) on top of your screen, showing you you carrier’s name, range, time and battery status.

statusbar

This part is very useful while developing applications – utilities, but as far as I remember, when I started programming I was really confused how to hide it.

While designing the view in Interface Builder in view’s attributes tab you can set Status Bar = None, but it’s still there. Nothing will happen if you set Status Bar property for MainWindow.xib.

If you would like to get rid of status bar you must do it in Xcode. It’s just a single line of code:

	[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
It will make the status bar vanish. If you want to remove it via alpha transition set animated:YES. If you don’t want to have status bar anywhere in whole your application, you should do it in implementation of AppDelegate file ([project_name]AppDelegate.m) before you will add any subviews to the window, for example:
- (void)applicationDidFinishLaunching:(UIApplication *)application {    
	MyView *viewController = [[MyView alloc] initWithNibName:@"MyView" bundle:[NSBundle mainBundle]];
	[window addSubview:[viewController view]];
	// Override point for customization after application launch
	[window makeKeyAndVisible];
}

Status bar’s styles

By default status bar is gray – shown as an image example above. You can quickly change it, so it will be like in Springboard (black) or during YouTube video playback (black translucent – showing what’s behind him).

barblack

bartranslucent

Code:

	[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:YES];
	[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
	[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];

As before using animated boolean property you can change the status bar with transition or without.

Orientation

There is another article about handling interface autorotation, but changing the status bar orientation is easy.

	[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
	[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
 	[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
	[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortraitUpsideDown animated:YES];

Please note: Using iPhone Simulator changing the orientation of status bar, automatically turn the defice to landscape / portrait mode, without changing the interface orientation (how to handle this, I will present in another tutorial).

That’s it. Sample project for you.

statusbarsimulator

xcodeproj

Download the project

Advertisement

8 comments

  1. Man-made Wig http://synthetic-wigs.dolabuy.com/ Net my wide range of trade name Fake Coat Wigs, Much longer Manufactured Hairpieces, Cut-rate Phony Wigs, Smaller False Hair pieces, At wholesale prices Manmade Wig plus more !

  2. Nick says:

    I really wish I hadn’t seen this as I really want one now! This is all very new to me and this article really opened my eyes.Thanks for sharing with us your wisdom. http://www.charmhandbags.com

  3. got any relevant consequence then I thought to look into the second one and got your blog. This is what I want!

  4. hey there and thank you for your info – I have certainly picked up something new from right here. I did however expertise some technical points using this site, since I experienced to reload the web site many times previous to I could get it to load correctly. I had been wondering if your web host is OK? Not that I am complaining, but slow loading instances times will sometimes affect your placement in google and could damage your high-quality score if advertising and marketing with Adwords. Well I’m adding this RSS to my e-mail and can look out for a lot more of your respective interesting content. Make sure you update this again very soon..

  5. Hi there, just became alert to your blog site through Aol, and found that it is really informative. I am gonna watch out for brussels. I will appreciate if you continue this in future. A lot of people will be benefited from your posting. All the best, Nia Macadangdang!

  6. Honestly I am not too familiar with this topic but I do like to visit blogs for layout ideas and interesting topics. Thank you for such orgnized post.

  7. Robbi Muto says:

    Brilliant blog posting. I found your post very interesting, I think you are a brilliant writer. I added your blog to my bookmarks and will return in the future.

  8. Good Forex says:

    nice! Really good sharing this. ;-)

Leave a Reply