title: Customized navigation bar does not receive touch events in entire view
body: <p>I am trying to implement this <a href="https://i.stack.imgur.com/Sb51o.jpg" rel="nofollow noreferrer">image of my implementation</a>.</p>
  
  <p>Where the three buttons below the uilabel are clickable. I have one UIView as a subview of my custom navigation bar view, then two views within that view, one is the uilabel and the second is the uiview of uibuttons i</p>
  
  <p>I've tried implementing solutions from other answers like </p>
  
  <pre><code>    override func hitTest(_ point: CGPoint, with event: UIEvent?) -&gt; UIView? {
      if self.point(inside: point, with: event) {
          self.isUserInteractionEnabled = true
      }else{
          self.isUserInteractionEnabled = false
      }
      return super.hitTest(point, with: event)
  }
  </code></pre>
  
  <p>But that didn't work. I noticed that if I tapped above the button near the position of the default uinavigation bar size then the tap is recognized.</p>
  
  <p>The size of my navigation bar is <code>CGSize(width: self.frame.size.width, height: 100)</code> if that helps.</p>
  
  <p><strong>Update</strong></p>
  
  <p>just adding my custom navigation class and it's usage</p>
  
  <pre><code>class CustomNavigationBar: UINavigationBar {
  override func sizeThatFits(_ size: CGSize) -&gt; CGSize {
      let newSize :CGSize = CGSize(width: self.frame.size.width, height: 100)
      return newSize
  }
  
  override func hitTest(_ point: CGPoint, with event: UIEvent?) -&gt; UIView? {
      if self.point(inside: point, with: event) {
          self.isUserInteractionEnabled = true
      }else{
          self.isUserInteractionEnabled = false
      }
      return super.hitTest(point, with: event)
  } 
  </code></pre>
  
  <p>}</p>
  
  <pre><code>    let navigationController = UINavigationController(navigationBarClass: CustomNavigationBar.self, toolbarClass: nil)
      navigationController.setViewControllers([mainController], animated: false)
  
      self.window?.rootViewController = navigationController
      self.window?.makeKeyAndVisible()
  </code></pre>