[英]How to delete a rect in a UIImage on iOS?
How can i delete a rect area in a UIImage? 如何删除UIImage中的矩形区域? My idea is i got a Solid colour image and a CGRect rectangle and i would like to deleted the CGrect in the UIImage so that the CGRect area will be transparent.
我的想法是我得到了一个纯色图像和一个CGRect矩形,我想删除UIImage中的CGrect,以便CGRect区域是透明的。 Please refer to the image below.
请参考下图。 The Semi-red is my uiimage and i would like to deleted the middle rect so that it is transparent for me to view the background image.
半红色是我的uiimage,我想删除中间的rect,以便对我来说查看背景图像是透明的。
CGContextClearRect(上下文,your_rect)
UIImage *yourImage;
CGRect imageRect = CGRectMake(0, 0, yourImage.size.width, yourImage.size.height);
CGRect grayRect = CGRectMake(20, 20, 20, 20);
CGRect rects[2] = {
imageRect,
grayRect
};
CGContextClipToRects(context, rects, 2);
[yourImage drawInRect:imageRect];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.