我有一个图像 .PNG(例如只有黑色轮廓的动物图像),我想通过触摸 iPad 屏幕来填充渐变。
我从这里遵循 Apple 的指南
遵循 Apple 的指南:
- (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; }
我只想知道如何在我的应用程序中使用此方法。
告诉我这样做的步骤是什么?
我是新手,请帮助我....