Hi I have an issue I can't figure out. I have wrote an extension that helps me colorize transparant PNG's
extension UIButton {
func setImageColorForState(image: UIImage, color: UIColor, forState: UIControlState) {
let temp = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
setImage(temp, forState: forState)
tintColor = color
}
}
I use the extension as follows:
btn.setImageColorForState(originalImage!, color: UIColor.yellowColor(), forState: .Highlighted)
btn.setImageColorForState(originalImage!, color: UIColor.grayColor(), forState: .Normal)
Somehow it only takes the last state only. So in this case the highlight state is ignored. What am I missing here?