How to pass the touch event to superview when userInteractionEnabled = YES?

后端 未结 6 1118
青春惊慌失措
青春惊慌失措 2020-12-17 14:24

I have the following setup.

+- XXXCustomControl : UIControl -------+
| A                                    |
|   +- ContentView -------------------+|
|   |         


        
6条回答
  •  臣服心动
    2020-12-17 14:48

    You can use another UIView to "hide" the subview.

    *Details : This UIView is the subview's sibling . it has the same size and position of your subview with background color of clear color.

    *Explain: The new UIView will take the touch, and automatically pass it to the superview.

    This way doesn't need to subclass your subview - it's a storyboard solution.
    Please try this. Have fun!

提交回复
热议问题