您的位置:首页 > 产品设计 > UI/UE

在iOS8系统下,UITabbar上的item自定义背景色和图片问题

2015-07-28 11:18 211 查看
在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"]];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: