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

UITabBarItem的selectedImage

2015-10-11 14:04 357 查看
TabBar使用频率很高的一个组件,TabBar的TabBarItem有两个属性一个是image(未选中图片),另一个是selectedImage(选中时图片)



但是运行时发现,选中时的图片变成了蓝色的,但是实际上图片是红色的,看来系统的TabBar会对图片默认使用TintColor再进行渲染。

解决方法:

1.设置渲染色

self.tabBarController.tabBar.tintColor = [UIColor blackColor];

2.设置图片不进行渲染

self.tabBarItem.selectedImage = [[UIImage imageNamed:@"XX"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

TabBarItem上标题颜色也可以修改

[self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor],NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: