Re: Change background color of UITabBarItem and UITabBar
Re: Change background color of UITabBarItem and UITabBar
- Subject: Re: Change background color of UITabBarItem and UITabBar
- From: Greg Reichow <email@hidden>
- Date: Tue, 26 Jan 2010 21:59:07 +0800
>
> Is it possible to change color of UITabBar instead of the default color black?
> And also is it possible to change background color of UITabBarItem's background
> color instead of default color blue? If yes, how?
There is no API for changing the UITabBar. Yet, you can subclass the TabBarController and override the viewDidLoad method. For example,
@interface UITabBarController (private)
- (UITabBar *)tabBar;
@end
@implementation CustomUITabBarController
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
UIView *v = [[UIView alloc] initWithFrame:frame];
[v setBackgroundColor:[UIColor redColor]];
[v setAlpha:0.5];
[[self tabBar] addSubview:v];
[v release];
}
@end
This would set a red tint to the tab bar. Check on stackoverflow.com for many more examples. Keep in mind the above example modifies the tabBar of the controller, which is specifically mentioned in the documentation not to mess with. So, use at your own risk.
Greg
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden