LoginSignup
6
6

More than 3 years have passed since last update.

自身のviewはタッチに反応させず親viewに任せるが子viewのタッチは反応させる

Last updated at Posted at 2017-06-22

isUserInteractionEnabled=falseだと子viewのタッチも反応しないから困るよねってやつ
古典的なやり方なせいかSwift版が見つからなかったんでメモ

  //UIViewのサブクラスでこのメソッドをオーバーライド
  override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
    let view = super.hitTest(point, with: event)
    return view == self ? nil : view
  }
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6