title: Swift pass through clicks in a child view controller
body: <pre><code>class PassThroughView: UIView {
      override func point(inside point: CGPoint, with event: UIEvent?) -&gt; Bool {
          for subview in subviews {
              if !subview.isHidden &amp;&amp; subview.isUserInteractionEnabled &amp;&amp; subview.point(inside: convert(point, to: subview), with: event) {
              return true
          }
      }
      return false
  }
  </code></pre>
  
  <p>I have a child view controller that takes up about 30% of the bottom space of my screen. This child view controller manages a few floating buttons.</p>
  
  <p>When user presses on the blank transparent regions between the floating buttons, touches are received by the child view controller and it is possible that there is a UIButton BEHIND the child view controller that the user wanted to touch, but cannot touch it because it is covered by the "transparent" region of the child view controller.</p>
  
  <p>I found some discussion about subclassing UIView and override the point inside function as above, but how to do this when i have a child view controller?</p>
  
  <p>p/s: Added a screenshot below to illustrate the problem. The child view controller manages 4 floating buttons. The child view controller has a default view and I set it to yellow color to be obvious. The blue information button is an example of a UIButton that is on the main view controller, covered by this view of the childviewcontroller.</p>
  
  <p><a href="https://i.stack.imgur.com/q2ZqO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q2ZqO.jpg" alt="enter image description here"></a></p>
  
  <p>p/s2: This is how the child view controller is added to main view:</p>
  
  <pre><code>private func createControlBar(){
      controlBarViewController = ControlBarViewController()
      controlBarViewController.view.translatesAutoresizingMaskIntoConstraints = false
      view.addSubview(controlBarViewController.view)
      controlBarViewController.delegate = self
  
      controlBarViewController.view.snp.makeConstraints { m in
          m.bottom.equalTo(view.snp.bottom)
          m.centerX.equalTo(view.snp.centerX)
          m.width.equalTo(view.snp.width)
          m.height.equalTo(180)
      }
  }
  </code></pre>
  
  <p>Where should I subclass the UIView?</p>