0

Is there a way to change the color of a UIImage when drawing it (like changing the tint color for a button image)? This is for IOS8 + Swift.

see below code where I would like to change the color of imageX

var imageY : UIImage = UIImage(named: "y.png")!
UIGraphicsBeginImageContext( imageY.size )
imageY.drawInRect(CGRect(origin: CGPointMake(0.0, 0.0), size: imageY.size))

var imageX : UIImage = UIImage(named: "x.png")!
imageX.drawInRect(CGRect(x: 10, y: 10, width: CGFloat(44), height: CGFloat(44)))

var newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext();
Brian
  • 14,610
  • 7
  • 35
  • 43
user2390340
  • 161
  • 2
  • 7
  • Is the image a grayscale image, or are you attempting to apply a tint to a full color image? – Simon Goldeen Aug 20 '15 at 22:19
  • can't you just override `touchesBegan`? – BenJammin Aug 20 '15 at 22:29
  • Hi Simon, yes this a black&white image. Im using the same image in toolbar & co where changing the tint color is ok. Trying to do the same here. I'm basically pasting 10 small icons to a bigger image and try to change the color of some of the icons. – user2390340 Aug 20 '15 at 23:16
  • if it helps I found the answer here .. http://stackoverflow.com/questions/19274789/how-can-i-change-image-tintcolor-in-ios-and-watchkit – user2390340 Aug 21 '15 at 18:50

0 Answers0