解决方法
首先,我假设你有一个UIBezierPath(iOS),而不是一个NSBezierPath(Mac OS X).
为此,您将需要使用核心图形,创建图像上下文,将UIImage绘制到该上下文中,然后清除NSBezierPath指定的区域.
// Create an image context containing the original UIImage. UIGraphicsBeginImageContext(originalImage.size); [originalImage drawAtPoint:CGPointZero]; // Clip to the bezier path and clear that portion of the image. CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddPath(context,bezierPath.CGPath) CGContextClip(context); CGContextClearRect(context,CGRectMake(0,originalImage.size.width,originalImage.size.height); // Build a new UIImage from the image context. UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();