I need to hide the right button in the Navigation Bar, then unhide it after the user selects some options.
Unfortunately, the following doesn\'t work:
In swift 4 I has a trick to show / hide right or left button:
Step 1: Create a IBOutlet button in view controller:
@IBOutlet var navigationItemButton: UIBarButtonItem!
Step 2: Create Hide button function:
func hideNavigationButton() {
navigationItemButton.isEnabled = false
navigationItemButton.tintColor = UIColor.clear
}
Step 3: Create Show button function:
func showNavigationButton() {
navigationItemButton.isEnabled = true
navigationItemButton.tintColor = UIColor.white
}
Step 4: Just call the functions that you want, use hideNavigationButton() to hide, and showNavigationButton() to show the button.
Regards!