HI ALL,
I want to draw transparent view on touch event, i.e I can erase section of the UIImageView so that I can see what is behind the UIImageView.
I am getting this but on touch, it erase the image in square shape,
I want this in round shape.
this is my code:
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
//CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15);
CGContextSetAlpha(UIGraphicsGetCurrentContext(), 0);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);// kCGBlendModeClear);
CGContextSaveGState(UIGraphicsGetCurrentContext()); //Probably right here
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(),
lastPoint.x,
lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),
currentPoint.x,
currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 20, 20));
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
//
This code works fine but it erase front Image in Square shape,
How can I make it in round shape?
can anybody help please?
Thanks.
I want to draw transparent view on touch event, i.e I can erase section of the UIImageView so that I can see what is behind the UIImageView.
I am getting this but on touch, it erase the image in square shape,
I want this in round shape.
this is my code:
UIGraphicsBeginImageContext(self.view.frame.size);
[drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), YES);
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
//CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15);
CGContextSetAlpha(UIGraphicsGetCurrentContext(), 0);
CGContextSetBlendMode(UIGraphicsGetCurrentContext(),kCGBlendModeNormal);// kCGBlendModeClear);
CGContextSaveGState(UIGraphicsGetCurrentContext()); //Probably right here
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(),
lastPoint.x,
lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),
currentPoint.x,
currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 20, 20));
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
//
This code works fine but it erase front Image in Square shape,
How can I make it in round shape?
can anybody help please?
Thanks.