iPhone: Adding a banner above the Navigation Controller.

Apple SDK or IB doesn't allow to add banner images to the top of the view.

Similar to the MySpace iPhone app's banner on the top of the Navaigation Views, we wanted to add a Banner Logo image on the top the Nav Controller.

Here's the solution:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


//create a view  for the banner logo add the banner to this view

UIImageView *logoImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_banner.png"]];

// put this banner above the nav bar ---> -30 as Y point means put it in the -30 Y-axis of the parent view --> which will be the tabbarcontroller.view.

UIView *bannerLogoView = [[UIView alloc] initWithFrame:CGRectMake(0,-30, 320, 30)];

[bannerLogoView addSubview:logoImage];

[logoImage release];

//add the tabcotroller as a subview of the view

[tabBarController.view addSubview:bannerLogoView];

[bannerLogoView release];

//Move the root view to show status bar & banner

tabBarController.view.frame = CGRectMake(0,50, 320, 430);

//add the modified logo view to window

[window addSubview:tabBarController.view];

[window makeKeyAndVisible];

return YES;








GammaPoint Tweets