//1.改变大小:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
for (UITabBarItem *item in tab.tabBar.items) {
item.imageInsets = UIEdgeInsetsMake(2, 2, 2,2);
}
//或者改变图片的大小即可,特别是@2x.png的图片大小
//2.改变颜色
[tabBar setSelectedImageTintColor:[UIColor redColor]];//如果没有选中的图片,这个可以改变图片颜色(ios7)
tabBar.tintColor=[UIColor greenColor];//ios8下
//3.消除tabbar边框
在appdelegate的程序启动处:
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc]init]];
//4.设置tabbar item原始图标与原始选中图标,而不是系统自动填充的颜色
UITabBar*tabBar = _tabBarController.tabBar;
UITabBarItem*item0= [tabBar.itemsobjectAtIndex:0];
UITabBarItem*item1= [tabBar.itemsobjectAtIndex:1];
UITabBarItem*item2= [tabBar.itemsobjectAtIndex:2];
UITabBarItem*item3= [tabBar.itemsobjectAtIndex:3];
// 5.对item设置相应地图片
item0.selectedImage= [[UIImageimageNamed:@"recognize-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
item0.image= [[UIImageimageNamed:@"recognize"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item1.selectedImage= [[UIImageimageNamed:@"life-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
item1.image= [[UIImageimageNamed:@"life"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item2.selectedImage= [[UIImageimageNamed:@"edit-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
item2.image= [[UIImageimageNamed:@"edit"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item3.selectedImage= [[UIImageimageNamed:@"setting-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];;
item3.image= [[UIImageimageNamed:@"setting"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//6.设置tabbar背景图片
UIView*backView = [[UIViewalloc]initWithFrame:CGRectMake(0,0, Main_Screen_Width,49)];
backView.backgroundColor= [UIColorredColor];
[self.tabBarinsertSubview:backViewatIndex:0];
self.tabBar.opaque=YES;