title: TouchesBegan always returns wrong UIView
body: <p>I want to detect when I'm touching somewhere else rather than a specific <code>UIView</code>. I'm using <code>touchesBegan</code> for it, however, it always prints "touch is outside" (see code below). What am I missing?</p>
  
  <p>I got help from this <a href="https://stackoverflow.com/questions/42385450/ios-how-to-hide-a-view-by-touching-anywhere-outside-of-it">post</a>.</p>
  
  <pre><code>override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      if let touch = touches.first {
          let hitView = self.view.hitTest(touch.location(in: self.view), with: event)
          if hitView === checkBackContainer {
              print("touch is inside")
          } else {
              print("touch is outside")
          }
      }
      super.touchesBegan(touches, with: event)
  }
  </code></pre>
  
  <p>Anchors added inside <code>ViewDidLoad</code> Function</p>
  
  <pre><code>private lazy var checkBackContainer = ImageUploadContainerView()
  
  override func viewDidLoad(){
  self.view.addSubview(checkBackContainer)
  checkBackContainer.anchorCenterXToSuperview()
  checkBackContainer.topAnchor.constraint(equalTo: checkFrontContainer.bottomAnchor, constant: 20).isActive = true
  checkBackContainer.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 25).isActive = true
  checkBackContainer.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -25).isActive = true
  checkBackContainer.heightAnchor.constraint(equalTo: checkBackContainer.widthAnchor, multiplier: 0.42).isActive = true
  checkBackContainer.layer.applySketchShadow(color: UIColor.white, alpha: 1.0, x: 0, y: 0.33, blur: 1, spread: 0, cornerRadius: 6)
  
  let backTap = UITapGestureRecognizer(target: self, action: #selector(self.backContainerTapped(_:)))
  checkBackContainer.addGestureRecognizer(backTap) }
  </code></pre>
  
  <p><strong>EDIT:</strong> ContainerView is a custom <code>UIView</code> which has some <code>UIStackView</code>s, <code>UIlabel</code>s and <code>UIImageView</code>s in it. I found that It is because a custom <code>UIView</code>, when I change it with a regular <code>UIView</code>. It is working.</p>