I have this code to draw lines on image user takes. I have successfully added feature to draw what ever the user feel like drawing on his/her image. But the lines which i draw is not smooth enough. I have tried the answers stack overflow experts suggested to others. But mine still looks rough. And one speciality is that I use pan gesture instead of touch, will that make any problems? Expert advices and codes are needed. Thanks in advance. Happy Coding. !
And this is from where I call the drawlineFrom method:
-(void)drawLineFrom:(CGPoint)from endPoint:(CGPoint)to
{
counter++;
bezierPath = UIBezierPath.bezierPath;
NSLog(@"UIGestureRecognizerStateChanged here");
[bezierPath moveToPoint: CGPointMake(from.x, from.y)];
[bezierPath addLineToPoint:CGPointMake(to.x, to.y)];
[bezierPath closePath];
bezierPath.usesEvenOddFillRule = YES;
box = [CAShapeLayer layer];
box.frame = CGRectMake(0, 0, 500, 500);
box.path = bezierPath.CGPath;
box.strokeColor = [UIColor colorWithRed:0.992 green:0.322 blue:0.212 alpha:1.00].CGColor;
box.fillColor = [UIColor colorWithRed:0.992 green:0.322 blue:0.212 alpha:1.00].CGColor;
box.lineWidth = 5;
[self.myImage.layer addSublayer:box ];
[layerarray addObject:box];
NSLog(@"AAAAARRRRTTTT%@",layerarray);
}
{
startPoint = [gesture locationInView:self.selfieImage];
if(gesture.state == UIGestureRecognizerStateChanged)
{
NSLog(@"Touched here \n :X-%f \n Y-%f",[gesture locationInView:self.selfieImage].x,[gesture locationInView:self.selfieImage].y);
startPoint = lastPoint;
lastPoint = [gesture locationInView:self.selfieImage];
[self drawLineFrom:startPoint endPoint:lastPoint];
}