我希望您能在图片上进行多点裁剪(请参见图片)。这很好用。我的问题是,在裁剪图像后,如何保存
UIImage
。我正在使用CAShapeLayer
来裁剪图像。下面的代码用于多点裁剪。- (void)multiPointCrop:(CGPoint)cropPoint
{
UIBezierPath *aPath = [UIBezierPath bezierPath];
[aPath moveToPoint:cropPoint];
for (NSString *pointString in self.touchPoints) {
if ([self.touchPoints indexOfObject:pointString] != 0)
[aPath addLineToPoint:CGPointFromString(pointString)];
}
[aPath addLineToPoint:cropPoint];
[aPath closePath];
[self setClippingPath:aPath andView:self];
[self setNeedsDisplay];
}
- (void)setClippingPath:(UIBezierPath *)clippingPath andView:(UIView *)view;
{
if (![[view layer] mask])
[[view layer] setMask:[CAShapeLayer layer]];
[(CAShapeLayer*) [[view layer] mask] setPath:[clippingPath CGPath]];
}
如何从CAShapeLayer
保存UIImage
?如果这是多个裁剪的正确方法或其他轻松实现此操作的方法,请提供您的想法、建议、源代码等,欢迎任何内容。