关于蒙面UIView的UIGestureRecogniser?

sob*_*dio 3 iphone core-graphics ipad uigesturerecognizer ios

有没有办法知道"点击"是否在UIView的屏蔽区域内部或外部?我正在使用CoreGraphics掩盖UIView.

点按位置图

到目前为止我的代码是这样的..

- (void)viewDidLoad {

    UIGestureRecogniser *r = [[UIGestureRecogniser alloc] initWithTarget:self action:@selector(gestCall:)];
    [self addGestureRecogniser:r];

}

- (void)gestCall:(UIGestureRecogniser *)gestRec {
     if ("somthing") {
        // outside of mask
     } else {
        // inside of mask
     }
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

sob*_*dio 5

我终于找到了我想要的解决方案.因此,为了任何一个试图找到的人的利益是CGPoint在任何CGPath内.

这很简单.

UIBezierPath *p = [UIBezierPath bezierPathWithCGPath:anyCGPath];

BOOL isInPath = [p containsPoint:anyCGPoint];
Run Code Online (Sandbox Code Playgroud)