我想对图像进行多点裁剪(见图)。它工作正常。我的问题是裁剪图像后如何保存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]];
}
如何UIImage
保存CAShapeLayer
?如果这是多重裁剪的正确方法或任何其他简单的方法来实现这一点。请给出你的想法、建议、源代码等。任何东西都欢迎。