-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
mouseSwiped = YES;
UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:scrollView];
//[self drawLine:lastPoint.x :lastPoint.y :currentPoint.x :currentPoint.y];
tempShapeLayer = nil;
CGMutablePathRef linePath = nil;
linePath = CGPathCreateMutable();
tempShapeLayer = [CAShapeLayer layer];
tempShapeLayer.lineWidth = 4.0f;
tempShapeLayer.lineCap = kCALineJoinMiter;
tempShapeLayer.strokeColor = [[UIColor redColor] CGColor];
CGPathMoveToPoint(linePath, NULL, lastPoint.x, lastPoint.y);
CGPathAddLineToPoint(linePath, NULL, currentPoint.x, currentPoint.y);
tempShapeLayer.path = linePath;
CGPathRelease(linePath);
[scrollView.layer addSublayer:tempShapeLayer];
lastPoint = currentPoint;
}
Я рисую линию этим кодом.но я хочу, чтобы эта линия оставалась прямой.означает, что когда я двигаю свое прикосновение, линия не должна становиться гладкой. Линия будет оставаться прямой.
Я думаю, мне нужно сделать что-то вроде
if (currentPoint.x > lastPoint.x){
currentPoint.y = lastPoint.y;
}
else if (currentPoint.x < lastPoint.x) {
currentPoint.x = lastPoint.x;
}