iphone - 屏蔽的 UIView 上的 UIGestureRecogniser?

标签 iphone ios ipad core-graphics uigesturerecognizer

有没有办法知道“点击”是在 UIView 的 mask 区域之内还是之外?我正在使用 CoreGraphics 来屏蔽 UIView。

Tap Location Diagram

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

- (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
     }
}

谢谢。

最佳答案

我终于找到了我一直在寻找的解决方案。因此,为了任何试图找到 CGPoint 的人的利益,CGPoint 位于任何 CGPath 中。

很简单。

UIBezierPath *p = [UIBezierPath bezierPathWithCGPath:anyCGPath];

BOOL isInPath = [p containsPoint:anyCGPoint];

关于iphone - 屏蔽的 UIView 上的 UIGestureRecogniser?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12977928/

相关文章:

ios - 使用 css 从 iPad safari 打印时如何删除或减少边距?

ios - 如何在 Storyboard 中使用大小类和自动布局?

iphone - 获取 iPhone 唯一 ID 的 API?

ios - 完成启动后或在我们的应用程序内启用/禁用推送通知

iphone - 在 iOS 应用程序中通过 WhatsApp 共享图像/文本

ios - 您可以使用 iOS6 SDK 构建但在 iPhone 5 上保留信箱吗?

swift - 在 iPad 上全屏显示 Swift Playgrounds

ios - CoreTelephony eSIM 功能无法在设备上运行

ios - react-native 的 Realm 给出 IOS 版本警告

iphone - Xcode 突然没有将图像加载到我的 Storyboard中(蓝色问号)