layer hit test only returning layer when bottom half of layer is touched

后端 未结 8 1988
闹比i
闹比i 2021-02-10 19:14

I have a sublayer on a layer-backed view. The sublayer\'s contents are set to an Image Ref and is a 25x25 rect.
I perform a hit test on the super layer when the touchesBega

8条回答
  •  醉酒成梦
    2021-02-10 19:30

    The accepted answer does not solve the problem, but the answer by schwa does.

    I have a window, a view controller and view. The view receives touches and calls hitTest: on its layer. I had the same problem and found out that the point in the view is correct, but in hitTest: the y coordinate of the point is 20px off, which happens to be the height of the status bar.

    By mapping the point to the coordinate system of the superlayer as suggested by schwa this problem is fixed. The "mysterious" superlayer is the root layer of the superview. In my case, it is the window layer (frame (0, 0, 320, 480)).

提交回复
热议问题