UIBezierPath: how to use - (BOOL) containsPoint: (CGPoint) point onPath: (UIBezierPath *) path inFillArea: (BOOL) inFill method for filling the image?

I have a .PNG image (for example, an animal with a black outline) and I want to fill the gradient by tapping the iPad screen.

I follow the Apple manual here

http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/BezierPaths/BezierPaths.html

Following Apple Guide:

- (BOOL)containsPoint:(CGPoint)point onPath:(UIBezierPath *)path inFillArea: (BOOL)inFill { NSLog(@"contains point Path %@", path); NSLog(@"Touch point %f %f", point.x, point.y ); CGContextRef context = UIGraphicsGetCurrentContext(); CGPathRef cgPath = path.CGPath; BOOL isHit = NO; // Determine the drawing mode to use. Default to detecting hits on the stroked portion of the path. CGPathDrawingMode mode = kCGPathStroke; if (inFill) { // Look for hits in the fill area of the path instead. if (path.usesEvenOddFillRule) mode = kCGPathEOFill; else mode = kCGPathFill; } // Save the graphics state so that the path can be removed later. CGContextSaveGState(context); CGContextAddPath(context, cgPath); // Do the hit detection. isHit = CGContextPathContainsPoint(context, point, mode); CGContextRestoreGState(context); return isHit; } 

I just want to know how I can use this method in my application.

Tell me, what are the steps for this?

I'm new to this, please help me ....

+4
source share

All Articles