My main goal of the image is to have a gray box above the image, and then when the user rubs into that gray box, it shows the image below. Basically, like a lottery card. I did a bunch of searches in the docs as well as on this site, but can't find a solution.
The following is just a proof of concept for checking the โerasureโ of an image based on where the user touches, but he doesnโt work. :(
I have a UIView that detects touches, then sends the coordinates of the move to the UIViewController, which pinned the image into a UIImageView by doing the following:
- (void) moveDetectedFrom:(CGPoint) from to:(CGPoint) to { UIImage* image = bkgdImageView.image; CGSize s = image.size; UIGraphicsBeginImageContext(s); CGContextRef g = UIGraphicsGetCurrentContext(); CGContextMoveToPoint(g, from.x, from.y); CGContextAddLineToPoint(g, to.x, to.y); CGContextClosePath(g); CGContextAddRect(g, CGRectMake(0, 0, s.width, s.height)); CGContextEOClip(g); [image drawAtPoint:CGPointZero]; bkgdImageView.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [bkgdImageView setNeedsDisplay]; }
The problem is that the strokes sent to this method are just fine, but nothing happens on the original.
Am I doing the wrong clip? Or?
Not quite sure ... so any help you may have would be greatly appreciated.
Thanks in advance, Joel
source share