Here is a partial answer to your question. This is a helper method that I wrote that grayscale image:
// baseImage is the grey scale image. color is the desired tint color + (UIImage *)tintImage:(UIImage *)baseImage withColor:(UIColor *)color { UIGraphicsBeginImageContextWithOptions(baseImage.size, NO, baseImage.scale); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGRect area = CGRectMake(0, 0, baseImage.size.width, baseImage.size.height); CGContextScaleCTM(ctx, 1, -1); CGContextTranslateCTM(ctx, 0, -area.size.height); CGContextSaveGState(ctx); CGContextClipToMask(ctx, area, baseImage.CGImage); [color set]; CGContextFillRect(ctx, area); CGContextRestoreGState(ctx); CGContextSetBlendMode(ctx, kCGBlendModeOverlay); CGContextDrawImage(ctx, area, baseImage.CGImage); UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); // If the original image was stretchable, make the new image stretchable if (baseImage.leftCapWidth || baseImage.topCapHeight) { newImage = [newImage stretchableImageWithLeftCapWidth:baseImage.leftCapWidth topCapHeight:baseImage.topCapHeight]; } return newImage; }
source share