我有一个应用程序,我有一个UIImageView显示主图像和另一个UIImageView被用作掩码,显示一个透明的圆形和不透明的外面,这个圆圈可以使用a移动UIPanGestureRecognizer,我想知道一个方法来裁剪里面的图像将圆圈变成新的图像.这是附加的代码和屏幕截图
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// create pan gesture
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self
action:@selector(handlePan:)];
[self.view addGestureRecognizer:pan];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [[self makeCircleAtLocation:self.view.center radius:100.0] CGPath];
shapeLayer.strokeColor = [[UIColor clearColor] CGColor];
shapeLayer.fillColor = nil;
shapeLayer.lineWidth = 3.0;
// Add CAShapeLayer to our view
[self.view.layer addSublayer:shapeLayer];
// Save this shape layer in a class property for future reference,
// namely so we …Run Code Online (Sandbox Code Playgroud)