Return to Snippet

Revision: 29324
at July 27, 2010 03:28 by mracoker


Initial Code
//header

#import <Foundation/Foundation.h>


@interface CustomUITabBarController : UITabBarController {

}

@end

//implementation

#import "CustomUITabBarController.h"


@interface UITabBarController (private)
- (UITabBar *)tabBar;
@end

@implementation CustomUITabBarController

-(float)rgbPercent:(int)rgb {
	int tmp = (rgb * 100) / 255;
	return [[NSString stringWithFormat:@".%i", tmp] floatValue];
}

- (void)viewDidLoad {
    [super viewDidLoad];
	
    CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
    UIView *v = [[UIView alloc] initWithFrame:frame];
	//UIColor *col = [UIColor colorWithRed:[self rgbPercent:0] green:[self rgbPercent:128] blue:1 alpha:1];
	UIColor *col = [UIColor colorWithRed:[self rgbPercent:128] green:1 blue:0 alpha:1];
    [v setBackgroundColor:col];
    [v setAlpha:0.5];
    [[self tabBar] addSubview:v];
    [v release];
	
}
@end

//////////////////////////
sample of use
//////////////////////////
CustomUITabBarController *tabBar = [[CustomUITabBarController alloc] init];
[window addSubview:tabBar.view];

Initial URL


Initial Description


Initial Title
CustomUITabBar with background color

Initial Tags
color

Initial Language
Objective C