Reputation: 1231
I am having a situation in which I have to hide the button on the right side of nav bar. Button name is btnRefresh, and I can hide it successfully by this way
self.nvbar.topItem?.rightBarButtonItem = nil
but when I use this for showing it again, it didn't get displayed again
self.nvbar.topItem?.rightBarButtonItem = btnRefresh
Any help???
Upvotes: 0
Views: 315
Reputation: 8396
You need to change the tint color to clear and disable the button as the following :
let barButtonItem = UIBarButtonItem()
barButtonItem.tintColor = .clear
barButtonItem.isEnabled = false
And to display it again change the color and enable it again :
barButtonItem.tintColor = .black
barButtonItem.isEnabled = true
Upvotes: 1