设置uitab bar 样式

/*

设置uitabr 样式

此方法需要设置了viewControllers 后设置了后调用

tabBar.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nil];

*/

-(void) setUITabBarStyle :(UITabBarController *)tabBar

{

for(UIView *view in tabBar.tabBar.subviews)

{

if([view isKindOfClass:[UIImageView class]])

{

[view removeFromSuperview];

}

}

UIImageView *imageView = [[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"teb.png"]]autorelease];

imageView.width = tabBar.tabBar.width;

imageView.height = tabBar.tabBar.height;

[tabBar.tabBar insertSubview:imageView atIndex:0];

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5"))

{

[tabBar.tabBar setSelectedImageTintColor:[UIColor whiteColor]];

UIImage *img = [UIImage imageNamed:@"tab_bg.png"];

UIImage *img1 = [img imageByScalingToSize:CGSizeMake(imageView.width/[[tabBar viewControllers]count],imageView.height)];

[tabBar.tabBar setSelectionIndicatorImage:img1];

}

}



你可能感兴趣的:(tab)