Home

Quick Tip: How to customise look of UITabBarController

A quickie, if you wanted to modify the look of a UITabBarController from the normal black colour, it's quite simple. No need to subclass even, I prefer thecategories methodology, which you should read up on and get familiar with, since it is extremely powerful, and quite simple to use.

Screen_shot_2011-04-22_at_10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma mark UITabBarController customisation to add background image
//In your appDelegate, just use categories to add functionality to UITabBarController
//overloading viewDidLoad. No need to subclass
@implementation UITabBarController (UITabBarControllerCategory)
- (void)viewDidLoad {
    [super viewDidLoad];
    
    CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
    UIImage *img = [UIImage imageNamed: @"uinavbar.png"];
    [imageView setImage:img];
    [imageView setAlpha:0.5];
    [[self tabBar] addSubview:imageView];
    [imageView release];
    
}
@end