[英]Why image shown in UITabBar, on selected item, not properly?
I have an UITabBar and set 2 images for a tab(active item, deactive item). 我有一个UITabBar并为选项卡(活动项目,非活动项目)设置2张图像。 On deactive item tab icon shown properly as:
在停用项选项卡上的图标正确显示为:
but when those item is active, icon not shown properly: 但是当这些项目处于活动状态时,图标将无法正确显示:
Can anyone help me to fix it? 谁能帮我修复它? I was that it will colour just borders of the icon, not entirely
我是说它只会为图标的边框着色,而不是全部着色
You need to use UIImageRenderingMode for that. 您需要为此使用UIImageRenderingMode。
UIImage *imgNormal=[UIImage imageNamed:@"normal.png"];
imgNormal=[imgNormal imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *imgSelected=[UIImage imageNamed:@"active.png"];
imgSelected=[imgSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tabBarItem.image = imgNormal;
tabBarItem.selectedImage = imgSelected;
Hope it helps :). 希望能帮助到你 :)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.