-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint tapLocation = [touch locationInView:self.superDrawingLayer];
lastPoint = tapLocation;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint tapLocation = [touch locationInView:self.superDrawingLayer];
currentPoint = tapLocation;
UIGraphicsBeginImageContext(self.superDrawingLayer.frame.size);
[self.superDrawingLayer.image drawInRect:CGRectMake(0, 0, self.superDrawingLayer.frame.size.width, self.superDrawingLayer.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), drwaingWidth);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeColor);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor colorWithRed:1.0f green:0.764705f blue:0 alpha:1.0] CGColor]);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextFlush(UIGraphicsGetCurrentContext());
self.superDrawingLayer.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = tapLocation;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
}
//Here superDrawingLayer is the ImageView on which lines will be drawn.