TO customize the color of UITabBar in Xcode
Hi Could you please let me know how to change the default colour of a tababar in Xcode i hav already tried this :
(void)viewDidLoad { [super viewDidLoad]; UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"UITabBar.png"]]; img.frame = CGRectOffset(img.frame, 0, 1); [tabBar1 insertSubview:img atIndex:0]; [img rele开发者_如何学编程ase];
but it doesnt work for me so can you please tel me in detail how can i change the colo
I know, this is an old thread, but nonetheless for all of you looking for an answer.
One of the ways to customize the look of UITabBar is to override drawRect:
method with use of categories. Choose to create new file in your Xcode project, choose Objective-C category, then type UITabBar for Category On textfield. Next, declare drawRect:
method in your category .h file and implement it in category .m file like this:
- (void)drawRect:(CGRect)rect {
UIImage *img = [UIImage imageNamed: @"tabbarBackground"];
[img drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
This will change the looks of all UITabBar instances in your app.
Hope this helps.
精彩评论