我正在使用以下代码在 imageview 的图像上画线,
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if ([touch tapCount] == 2)
return;
lastPoint = [touch locationInView:imageview];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:self.view];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), 3);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5);
UIGraphicsBeginImageContext(self.view.frame.size);
[imageview.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 5, 5));
imageview.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
}
输出
您可以看到点之间的间隙/空间。我需要输出应该如下所示,
我应该在我的代码中进行哪些更改以删除两个点之间的空格?
我认为,touchesended
您的审核不需要代码。我改变了 CGContextSetLineCap 和宽度,没有运气。