I have the next structure in swift 3:
Navigation Controller -> Tab Bar Controller -> 4 View Controllers
I have 3 commons bar buttons items. My problem is, in just one of the view Controllers I want to add new bar button item on the top-right corner. This way when I navigate to the others views the new button should not appear.
How can I solve this?
Thanks!
You should set it with tabBarController like this in Swift:
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "imageName"), for: .normal)
button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
let leftButtonBar = UIBarButtonItem(customView: button)
tabBarController?.navigationItem.rightBarButtonItems = [leftButtonBar].
this is best answer forever and works correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With