UIView. Why Does A Subviews Outside its Parent's Extent Not Receive Touches?

后端 未结 5 1160
盖世英雄少女心
盖世英雄少女心 2020-12-04 19:29

I have a simple - trivial - UIView parent/child hierarchy. One parent (UIView). One child (UIButton). The parents bounds are smaller then it\'s child\'s bounds so that a por

5条回答
  •  [愿得一人]
    2020-12-04 20:19

    • @dugla, thank you for the question!
    • @Bastian and @laoyur, thanks to you for answers!

    Swift 4

    override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
    
        if yourChildView.point(inside: convert(point, to: yourChildView), with: event) {
            return true
        }
    
        return super.point(inside: point, with: event)
    }
    

提交回复
热议问题