Add image modification block to render template images w/ tint.

This commit is contained in:
andyscott
2015-02-03 12:54:41 -08:00
parent 6246f077fc
commit 4bd9ef2927
2 changed files with 29 additions and 0 deletions

View File

@@ -373,3 +373,20 @@ extern asimagenode_modification_block_t ASImageNodeRoundBorderModificationBlock(
return modifiedImage;
};
}
extern asimagenode_modification_block_t ASImageNodeTintColorModificationBlock(UIColor *color)
{
return ^(UIImage *originalImage) {
UIGraphicsBeginImageContextWithOptions(originalImage.size, NO, originalImage.scale);
// Set color and render template
[color setFill];
UIImage *templateImage = [originalImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[templateImage drawAtPoint:CGPointZero];
UIImage *modifiedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return modifiedImage;
};
}