This is the menu for my app and I generate different color themes such as:
I'm using the following method to recolor each menu items icon:
func recolorImage(imgView: UIImageView, toColor: UIColor) {
let imgTintColor = imgView.image!.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
imgView.image = imgTintColor
imgView.tintColor = toColor
}
After calling the function, I get the result below where I'm losing the gradient:
Sorry in advance for my ignorance (still a newbie), it seems to be that the method will remove all colors, including gradients and then apply the tintcolor.
I wonder if there is another function to do the job? Or should I create custom class with a gradient mask applied to each icon (link to another thread) or export a specific colored png for each icon which would be counter productive in my opinion?
Any help would be well appreciated :D
Thanks!