【问题标题】:Using CGPathContainsPoint on CAShapeLayer.path After Moving the Layer移动图层后在 CAShapeLayer.path 上使用 CGPathContainsPoint
【发布时间】:2012-08-27 13:53:42
【问题描述】:

使用 CGPathContainsPoint 时,我的结果与 CAShapeLayer 的原始位置一致,但与当前位置不一致。这是正常的吗,我是否需要在我正在测试的 CGPoint 上应用转换,或者我应该在代码的其他地方寻找问题?我的 CAShapeLayer 只是通过一次更新其 .position 属性来移动。

为了完整起见,我补充说我的 CAShapeLayer 是 UIButton.layer 的子层。

【问题讨论】:

    标签: objective-c cgpath cashapelayer


    【解决方案1】:

    为了回答我自己的问题,我需要使用以下方法将触摸点的位置(在 UIButton 的坐标空间中)转换为 CAShapLayer 的坐标空间:

    CGPoint convertedTouchPoint = [myButton.layer convertPoint:touchPoint toLayer:myShapeLayer];
    

    【讨论】:

    • 8年后救我)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-16
    相关资源
    最近更新 更多