读书人

设立uitab bar 样式

发布时间: 2013-03-22 09:49:50 作者: rapoo

设置uitab bar 样式

/*

设置uitabr 样式

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

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

*/

-(void) setUITabBarStyle :(UITabBarController *)tabBar

{

for(UIView *viewin tabBar.tabBar.subviews)

{

if([viewisKindOfClass:[UIImageView class]])

{

[view removeFromSuperview];

}

}

UIImageView *imageView = [[[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"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 = [UIImageimageNamed:@"tab_bg.png"];

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

[tabBar.tabBar setSelectionIndicatorImage:img1];

}

}



读书人网 >移动开发

热点推荐