在iOS8系统下,UITabbar上的item自定义背景色和图片,初始设置了红色没效果系统默认颜色-蓝色
解决方法:
//选择的图片
UITabBar *tabBar = self.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
tabBarItem1.title = @"title1";
tabBarItem2.title = @"title2";
UIImage* selectedImage = [UIImage imageNamed:@"xxxx.png"];
//声明这张图片用原图(别渲染)
selectedImage = [selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[tabBarItem1 setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:[UIImage imageNamed:@"xxx.png"]];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"xxxx.png"]withFinishedUnselectedImage:[UIImage imageNamed:@"xxxx.png"]];