1

I have been searching for a way to customize the UIKit's UITabBarController. I would like to change the background image and selected tint color to follow the design from our creative team. It seems as though the background color can be altered as described here Changing Tint / Background color of UITabBar

However, I have not found a way to change the background to an image and the default 'blue' tint to another color. There are many apps in the appstore which use custom tabbars like so:

http://itunes.apple.com/th/app/project-noah/id417339475?mt=8

Please help. Thank you.

Community
  • 1
  • 1
user855723
  • 21
  • 5

1 Answers1

0

Its not UITabbarController in this link

http://itunes.apple.com/th/app/project-noah/id417339475?mt=8

its a UIToolbar.

you can do it by creating a category for UIToolBar

@interface UIToolBar(CustomImage)
- (void)drawRect:(CGRect)rect;
@end


@implementation UIToolbar (CustomImage)
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"imageToolbar.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    [super drawRect:rect];
}
@end
Shrey
  • 1,959
  • 2
  • 21
  • 44
  • Thank you. Do I need to explicitly call the method drawRect? The drawRect method is not executing automatically and the image is not showing. – user855723 Aug 04 '11 at 09:45
  • i've edited the above code.. actually i forgot to put `[super drawRect:rect];` at the last of the function. – Shrey Aug 04 '11 at 11:20
  • No, you dun have to call it explicitly. – Shrey Aug 04 '11 at 11:20
  • Thanks Shrey, however the drawRect method is still not getting executed. Rather than use a category, I am going to insertSubview as someone has suggested to me like so: [toolbar insertSubview:[ [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"toolbarBG.png"]] autorelease] atIndex:0]; – user855723 Aug 05 '11 at 04:36
  • Here is a reference to that solution: http://stackoverflow.com/questions/3501363/iphone-uitabbar-custom-image-doesnt-work – user855723 Aug 05 '11 at 05:00