ios - pointInside :withEvent inside uibezierpath (overlapping area between two views)

标签 ios xcode xcode7 uibezierpath

无论我尝试了多少,我都无法访问(处理滚动/触摸事件)两个方形 View A 和 B(A 在 B 顶部)之间的重叠区域(直角三角形),如图所示

enter image description here

我想要由 UIbezierpath 定义的右侧部分(三角形 B)来处理其下方 View (即 B)的滚动。我无法通过 pointInside: withEvent: 访问它,因为它是 bezierpath。 甚至 touchesBegan:withEvent: 也根本不起作用

 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint touchPoint = [touch locationInView:self.view];
    if ([leftPath containsPoint:touchPoint])
    {  //Do something
     }
 }

请帮忙。

最佳答案

您必须实现 UIView 的 hitTest 方法来检测特定 View 上的触摸。只需将您的 View 子类化并实现 hitTest 方法。

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{

if ([path containsPoint:point]){

    return [super hitTest:point withEvent:event];
}
else{

    return nil;
}

}

关于ios - pointInside :withEvent inside uibezierpath (overlapping area between two views),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34370512/

相关文章:

ios - 使用控制台模式进行调试

iphone - 重命名的项目将无法运行

ios - 用于内部开发的 IPA 文件

XCode 8 错误 "Project ERROR: Xcode not set up properly",即使许可证已被接受

swift - 无法将 Xcode7 中类型 'String' 的值分配给类型 'String' 的值

ios - Xcode 7 GM 无法提交(GIT)

ios - Xcode UI 测试找不到以编程方式添加的 View

ios - 如何解释 XCode 核心数据中的删除规则?

ios - 使用 PFFFacebookUtilsV4 Cocoapods 在 Swift 中获取 Facebook 用户详细信息

ios - 同一 ViewController 的 3D Touch 快速操作