2

I have a viewcontroller with button "close" which is located on the navigation bar place. That's how it looks:

enter image description here

The code where I hide navigation bar:

    self.navigationController!.navigationBar.setBackgroundImage(UIImage(), for: .default)
    self.navigationController!.navigationBar.shadowImage = UIImage()
    self.navigationController!.navigationBar.isTranslucent = true
    navItem.setHidesBackButton(true, animated: true)

The button is visible but touch up event doesn't work. If I move button below navigation bar area everything works fine.

I tried :

    self.navigationController!.navigationBar.isUserInteractionEnabled = true
    self.navigationController!.navigationBar.isExclusiveTouch = false

Unfortunately, it didn't help. How can I fix this issue?

Dima
  • 1,189
  • 1
  • 8
  • 12
  • Your code should work, still if you are facing button calling problem then there must be issue somewhere else, Can you please share your code zip here so I can help you – Dhara Patel Apr 24 '20 at 11:24
  • Hi, is it working like this or completely not working? https://stackoverflow.com/questions/61278358/navigationbar-buttons-click-area-not-working-properly-image-is-not-clickable – Clown Apr 24 '20 at 12:22
  • 1
    Is there a reason you don't **hide** the navigationBar? `self.navigationController?.setNavigationBarHidden(true, animated: false)` – DonMag Apr 24 '20 at 13:47

1 Answers1

0

Isn't the Close button a navigationBar button?

navigationItem.rightBarButtonItem?.isEnabled = true

navigationItem.rightBarButtonItem = UIBarButtonItem(title: "CLOSE", style: .done, target: self, action: #selector(handleRightBarButton))

@objc handleRightBarButton()
{
    //Hide function here? 
}
daj mi spokój
  • 248
  • 1
  • 2
  • 8