How erase part of UIImage with an other UIImage
I posted that question and I开发者_开发技巧 have not yet found a solution.
I was wondering if there is a way to use anUIImage
to delete a part of an other UIImage
I would use an UIImage
to 'mask' this ugly black background to let a transparency color.
CGContextAddPath
but I don't know how to use it...
Regards,
KL94Simple solution
- (UIImage*)eraseImage:(UIImage*)img1 WithImage:(UIImage*)img2
{
UIGraphicsBeginImageContext(img1.size);
[img1 drawInRect:CGRectMake(0, 0, img1.size.width, img1.size.height)];
[img2 drawInRect:CGRectMake(0, 0, img2.size.width, img2.size.height) blendMode:kCGBlendModeDestinationIn alpha:1.0];
UIImage* result_img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result_img;
}
But you better save image as transparent.(Like PNG)
精彩评论