title: Detect that user tap on screen Swift
body: <p>I want to remove <code>UIView</code> from screen after user tap something except that view. (to visualize it for you I will upload sketch of my view)</p>
  <p><img src="https://i.stack.imgur.com/YHY7w.png" alt="enter image description here" /></p>
  <p>And I want to remove blue <code>UIView</code> after user tap on something except buttons in this view. What should I use?</p>
  <p>EDIT:
  In blue <code>UIView</code> are two buttons and I want to remove that view when user tap on background image</p>
  <p>I did what @yerpy told me to do but it isn't working.</p>
  <pre><code>func test(gestureRecognizer: UITapGestureRecognizer) {
      print(&quot;test&quot;)
  }
  
  func setUpBackgroundImageView() {
      self.view.addSubview(backgroundImageView)
      backgroundImageView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
      backgroundImageView.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true
      backgroundImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      backgroundImageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
      let tap = UITapGestureRecognizer(target: self, action: #selector(test(gestureRecognizer:)))
      backgroundImageView.addGestureRecognizer(tap)
      tap.delegate = self
  }
  </code></pre>
  <p>And I also add <code>shouldReceiveTouch</code> function  to <code>UIGestureRecognizerDelegate</code>. What am I doing wrong?</p>