我已经完成了从图库或相机获取图像。当我点击该按钮从画廊或相机再次获取图像时,我有按钮,当我触摸突出显示应该只显示在anotherView.remaing中的某些部分时部分应该被删除。请任何人协助我如何做到这一点。帮助我们。我写了这段代码
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
self.slider.hidden=NO;
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:self.view]; //lastTouch is CGPoint declared globally
}
//#pragma mark - Touch moved mehotd
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
currentPoint = [touch locationInView:self.view1]; //currentTouch is CGPoint declared globally
CGColorRef strokeColor = [UIColor whiteColor].CGColor;
UIGraphicsBeginImageContext(view1.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[imageView1.image drawInRect:CGRectMake(0, 0, self.view1.frame.size.width, self.view1.frame.size.height)];
//canvasView is your UIImageView object declared globally
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, slider.value);
CGContextSetStrokeColorWithColor(context, strokeColor);
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextBeginPath(context);
CGContextMoveToPoint(context, lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y);
CGContextStrokePath(context);
imageView1.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = [touch locationInView:self.view1];
}
//#pragma mark - Touch end mehotd
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
currentPoint = [touch locationInView:self.view1];
}
但它正在删除选定的区域。但我不想删除所选区域(突出显示)。未选择的部分应该被删除。我试了很多请任何机构回复我如何做到这一点。帮助我们
答案 0 :(得分:1)