The structure is the following:
In my storyboard, I have a Tab Bar Controller
which contains a Tab Bar
object. This object has a custom cla
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.
Setting non-selected image to always original render and selected one to always template render did the trick for me.
Solution for iOS 13 and swift 5.1
let item = UITabBarItem(title: "item_title",
image: UIImage(named: "img")?.withRenderingMode(.alwaysOriginal),
selectedImage: UIImage(named:"img_selected")?.withRenderingMode(.alwaysTemplate))
Swift 3:
for item in self.tabBar.items!{
item.selectedImage = item.selectedImage?.withRenderingMode(.alwaysOriginal)
item.image = item.image?.withRenderingMode(.alwaysOriginal)
}