有没有一种方法可以知道'tap'是在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
}
}
谢谢。
最佳答案
我终于找到了我想要的解决方案。因此,对于任何尝试查找的人来说,任何CGPath内都应包含一个CGPoint。
这很简单。
UIBezierPath *p = [UIBezierPath bezierPathWithCGPath:anyCGPath];
BOOL isInPath = [p containsPoint:anyCGPoint];