iPhone Development – UINavigationBar Background Image

Most iPhone development projects work just fine without the need to customize the appearance of the navigationBar. But once in a while you probably would like to change the background of the navigationBar.

Your RootViewController has acces to a NavigationItem, which has a property titleView. This view holds the title of your current active view in the navigationControllers stack. However setting the titleView to one of your customViews, will not take up the whole background of the NavigationBar. This is because the NavigationBar consists of not only the titleView, but also has room for the default back button an perhaps another UIButton at the right.

If you want a custom background for your navigationBar, and still want to maintain the ability place custom labels on top of it, without having to worry about views disappearing behind the background you have set, the following snippet will help you to do just that.

Open your application MyAppDelegate.m and place the following implementation above the implementation of our MyAppDelegate.



//Overide the drawing of the background UINavigationBar
@implementation UINavigationBar (image)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"my_navigation_bar_bg.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

What it does is, whenever the application tries to draw the navigationBar, it uses the image “my_navigation_bar_bg.png” as your source to draw the containing rect of the navigationBar. So all other UIElements are draw on top of this image. The default height of the navigationBar is 44 pixels. So an image of 320×44 will fill up the total space behind all navigationItems in this application.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter
  • MySpace
  • NuJIJ

Ferrofluid

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter
  • MySpace
  • NuJIJ

Dropbox app for iPhone

dropbox iphone app

For all those dropbox user this app will need no introduction, but for the people who don’t.

You will need a dropbox if:

  • You want to access your music files, cross-platform from any computer you installed dropbox on.
  • You work on multiple locations and want your files to be in sync, without you thinking about.
  • Share your files to your friends, either by email. Simply invite trusted user to your dropbox

If you think this is handy and you own an iphone, then the newly released iPhone app is just the thing for you.

You get all the above benefits, but now you can use it on the run. A nice feature and if you filled you iPhone memory with useless but ow so funny apps, you can use the extra 2GB storage.

Best part of it all….it’s free.

Get the app here

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter
  • MySpace
  • NuJIJ