// Construct new image the same size as the one passed.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
UIImage *image; UIGraphicsBeginImageContextWithOptions([self size], NO, 0.0); // 0.0 value for scale means "scale for device's main screen". CGRect rect = CGRectZero; rect.size = [self size]; // initializing a rect with the size of the original image. // tint the image [self drawInRect:rect]; [color set]; // setting the color to be filled as "color", which is a UIColor object to which we are going to tint the image. UIRectFillUsingBlendMode(rect, kCGBlendModeColor); // Filling the created rect using the blend mode, kCGBlendModeColor // restore alpha channel [self drawInRect:rect blendMode:kCGBlendModeDestinationIn alpha:1.0f]; image = UIGraphicsGetImageFromCurrentImageContext(); // image will contain the final tinted image UIGraphicsEndImageContext(); return image; |



