Posted By

espinallab on 04/11/10


Tagged

custom backgroundUINavigationBar


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
wpellis
cnathan


Custom background for UINavigationBar


 / Published in: Objective C
 

URL: http://discussions.apple.com/thread.jspa?threadID=1649012&tstart=0

This works well for me, and doesn't appear to have issues with pushing new view controllers, hidden titles and bar button items, etc.

To implement it just copy and paste this line before you ViewController @implementation file. Example:

// // MenuViewController.m // Restaurant // // Created by Eddie on 4/10/10. // Copyright 2010 MyCompanyName. All rights reserved. //

import "MenuViewController.h" import "CheckoutViewController.h"

@implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed: @"grayGB.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end

@implementation MenuViewController

@synthesize tableView, menuArray;

  1. @implementation UINavigationBar (CustomImage)
  2. - (void)drawRect:(CGRect)rect {
  3. UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
  4. [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
  5. }
  6. @end

Report this snippet  

You need to login to post a comment.