Preserving the original image color of the selected and unselected UITabBar icons
Just go to your image assets properties, and set Render as property to "original image"
And you're good to go!
Perfect question, really well explained.
You are not setting imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal
for the selected image.
Just should add imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal
to the selectedImage
:
item.selectedImage = [[UIImage imageNamed:[imageName stringByAppendingString:@"-selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
Check this other answer.
Swift 3:
for item in self.tabBar.items!{
item.selectedImage = item.selectedImage?.withRenderingMode(.alwaysOriginal)
item.image = item.image?.withRenderingMode(.alwaysOriginal)
}