I am creating a tabBar application in xCode 4.3.2 with UINavigation controller. I am using following code in AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; // Override point for customization after application launch. UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease]; UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease]; self.tabBarController = [[[UITabBarController alloc] init] autorelease]; self.tabBarController.viewControllers = [NSArray arrayWithObjects: [[[UINavigationController alloc] initWithRootViewController:viewController1] autorelease], viewController2, nil]; self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible]; return YES; } Now problem is that i want custom background image in navigation bar. The solutions i have found are writing subclass of UINavigationBar and set new subclass in interface builder. But in my case i am setting navigation controller programmatically then how to achieve this? I have also tried creating category as
@implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed:@"NavigationBar.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end But its not working at all.