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

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

    /// Add frame.origin.y

        public override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
            let convertPoint = CGPoint(x:point.x, y:(point.y + frame.origin.y))
            let superPiont = self.layer.convert(convertPoint, to:layer.superlayer)
            selectlayer = layer.superlayer?.hitTest(superPiont)
            }
    

提交回复
热议问题