【问题标题】:Determining which CGPath was tapped确定哪个 CGPath 被点击
【发布时间】:2014-03-04 21:55:48
【问题描述】:

我正在寻找我称之为 CGPathContainsPoint 的倒数的东西。我在 UIView 中有一系列可点击区域,如果用户点击,我需要找出用户点击的区域。

除了使用 CGPathContainsPoint 来检查每个区域,有没有更好的方法来简单地确定哪个 CGPath 被点击了?

谢谢!

【问题讨论】:

    标签: ios objective-c uiview core-graphics


    【解决方案1】:
    if (CGPathContainsPoint(path, NULL, touchpositionInView, NO)){
    BOOL PathContainsPoint = YES;
    }
    
    if (CGPathContainsPoint(path2, NULL, touchpositionInView, NO)){
    BOOL Path2ContainsPoint = YES;
    }
    //...
    

    我看不出这段代码有什么问题?

    【讨论】:

    • 我真正想要的是一种更有效的检查方式,即能够识别点击了哪个 CGPath,而无需单独检查每一个。
    • 啊,我想我明白你的意思了。您可以通过执行 pathByAddingPath 来组合您的路径。然后 if(!pathcontainspoint(combinedPath,NULL, touchpositioninview,NO){ nslog(@"something here"); }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    • 2020-04-12
    相关资源
    最近更新 更多