Code for Remove Layer (UIImageView) on Particular View

Hello Friends ,

below is code to remove with touch moved.

– (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

if(eraseOn == TRUE)
UITouch *touch = [touches anyObject];
lastTouch = [touch locationInView:self.drawImage];

UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view]; = location; */

– (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

if(eraseOn == TRUE){
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:self.drawImage];
CGFloat brushSize = 5;
CGColorRef strokeColor = [UIColor whiteColor].CGColor;
CGContextRef context = UIGraphicsGetCurrentContext();
[self.drawImage.image drawInRect:CGRectMake(0, 0, self.drawImage.frame.size.width, self.drawImage.frame.size.height)];
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, brushSize);
CGContextSetStrokeColorWithColor(context, strokeColor);
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextMoveToPoint(context, lastTouch.x, lastTouch.y);
CGContextAddLineToPoint(context, currentTouch.x, currentTouch.y);
self.drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
lastTouch = [touch locationInView:self.drawImage];
else {

// [self touchesBegan:touches withEvent:event];


– (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {


And at below Link u can request for demo example ( how to integrate tutorial )



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s