问题
I have an UITabBar and set 2 images for a tab(active item, deactive item). On deactive item tab icon shown properly as:
Image here
but when those item is active, icon not shown properly:
Image here
Can anyone help me to fix it? I was that it will colour just borders of the icon, not entirely
回答1:
- Check this screenshot: At right side of the screen see 'Rendered as' text and select drop down and use Original image. Your problem would be solved. Hope this helps..
回答2:
You need to use UIImageRenderingMode for that.
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 :).
来源:https://stackoverflow.com/questions/37236168/why-image-shown-in-uitabbar-on-selected-item-not-properly