我正在创建一个应用程序,我试图在其中清除rect
. UIImageView
我已经用 实现了这一点CGContextClearRect
,但问题是它rect
以方形清除,我想以圆形实现这种效果。
到目前为止我已经尝试过:
UITouch *touch2 = [touches anyObject];
CGPoint point = [touch2 locationInView:img];
UIGraphicsBeginImageContextWithOptions(img.bounds.size, NO, 0.0f);
[img.image drawInRect:CGRectMake(0, 0, img.frame.size.width, img.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect cirleRect = CGRectMake(point.x, point.y, 40, 40);
CGContextAddArc(context, 50, 50, 50, 0.0, 2*M_PI, 0);
CGContextClip(context);
CGContextClearRect(context,cirleRect);
//CGContextClearRect(context, CGRectMake(point.x, point.y, 30, 30));
img.image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();