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?

3
  • 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 Commented Apr 24, 2020 at 11:24
  • Hi, is it working like this or completely not working? stackoverflow.com/questions/61278358/…
    – Clown
    Commented Apr 24, 2020 at 12:22
  • 1
    Is there a reason you don't hide the navigationBar? self.navigationController?.setNavigationBarHidden(true, animated: false)
    – DonMag
    Commented Apr 24, 2020 at 13:47

1 Answer 1

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? 
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.