相关疑难解决方法(0)

检测触摸UIBezierPath笔划,而不是填充

可能重复:
如何检查用户是否在CGPath附近轻敲?

我正在从这里关注Apple的指南

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

尝试仅在我的UIBezierPath的描边部分检测触摸事件.如果我使用UIBezierPath方法containsPoint,它工作正常,但它检测笔划和UIBezierPath的填充部分上的触摸事件,我希望它只发生在描边部分.

按照Apple的指南(在链接的清单3-6),我创建了这个功能:

- (BOOL)containsPoint:(CGPoint)point onPath:(UIBezierPath*)path inFillArea:(BOOL)inFill
{
    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 …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c

7
推荐指数
1
解决办法
4716
查看次数

标签 统计

cocoa-touch ×1

iphone ×1

objective-c ×1