繁体   English   中英

如何用其他UIImage擦除部分UIImage

[英]How erase part of UIImage with an other UIImage

我发布了该问题 ,但尚未找到解决方案。
我想知道是否有一种方法可以使用UIImage删除其他UIImage的一部分 替代文字

我会使用UIImage来“遮盖”这个丑陋的黑色背景,以产生透明色。
也许与CGContextAddPath但我不知道如何使用它...

问候,
KL94

简单的解决方案

- (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;
}

但是您最好将图像另存为透明。(例如PNG)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM