美文网首页
iOS tabbar 设置图片,与展示不一样

iOS tabbar 设置图片,与展示不一样

作者: 06f43b0b52f7 | 来源:发表于2017-09-27 15:23 被阅读350次

是因为tabbar对图片会默认有渲染效果
iOS之tabbar图片去除渲染以及字体颜色统一配置
转发:http://www.cnblogs.com/qianLL/p/5521228.html

方式一
代码实现 这种要写很多代码 ,每个控制器都要写
UIImage *image=[UIImage imageNamed:@"tabBar_friendTrends_click_icon"];
// 不让tabbar底部有渲染的关键代码
image=[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc01.tabBarItem.selectedImage=image;

更改tabbar下方的文字样式,大小, 颜色
NSMutableDictionary *atts=[NSMutableDictionary dictionary];
// 更改文字大小
atts[NSFontAttributeName]=[UIFont systemFontOfSize:12];
// 更改文字颜色
atts[NSForegroundColorAttributeName]=[UIColor darkGrayColor];

NSMutableDictionary *selectedAtts=[NSMutableDictionary dictionary];
selectedAtts[NSFontAttributeName]=[UIFont systemFontOfSize:12];
selectedAtts[NSForegroundColorAttributeName]=[UIColor greenColor];
[vc01.tabBarItem setTitleTextAttributes:selectedAtts forState:UIControlStateSelected];

相关文章

网友评论

      本文标题:iOS tabbar 设置图片,与展示不一样

      本文链接:https://www.haomeiwen.com/subject/htuuextx.html