I have a UIImage that is displaying a grayscale button. Is there a way to “shade” the image with a color when i draw it? So i could effectively have 1 grayscale button image, but have any color button? I would also like to have the transparent pixels stay transparent if possible.
Thanks!
To do this, you’ll need to use Quartz 2D with the following steps:
CGImagefor the PNG background withCGImageCreateWithPNGDataProvider, or useUIImageas usual and grab a reference to the Quartz image data using theCGImageproperty of theUIImage.CGContextSetBlendMode. The mode you’re after is probablykCGBlendModeOverlay.CGImagefor the shading layer.CGContextDrawImageto composite the shading layer over the background layer.Detailed instructions on how to do this are available in the Quartz 2D Programming Guide, in the section titled “Using Blend Modes with Images”.