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

后端 未结 8 1991
闹比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:40

    When I try your code, I get almost-correct behavior, except touches are often not recognized on the very edge of the sublayer. I am a bit confused as to what's going on. You might want to try doing something like when you register a touch, throw a new tiny layer up where the touch occurred (like a 5x5 square of some color) and then remove it again 3 seconds later. That way you can track where CA thinks the touch occurred versus where your cursor actually is.

    BTW, you don't need to create a CGImage for your blue content, you can just set the layer's backgroundColor to [UIColor blueColor].CGColor.

提交回复
热议问题