Hiding UINavigationItem's bar button

后端 未结 11 1061
粉色の甜心
粉色の甜心 2021-01-04 07:04

I have added a BarButton item to the left of the nav.bar through Interface Builder and in the code I want this only to show in my table view\'s edi

11条回答
  •  余生分开走
    2021-01-04 07:21

    I have a easy function to make this. I have a navigation like this. It comes form Interface Builder, it has a background image.

    @IBOutlet weak var memberBtn: UIBarButtonItem!
    

    you can hide/show it by:

    func hideMemberBtn() {
        memberBtn.isEnabled = false
        memberBtn.tintColor = UIColor.clear
    }
    func showMemberBtn() {
        memberBtn.isEnabled = true
        memberBtn.tintColor = UIColor.white
    }
    

    It's easy but it work for me. You can change tintColor as you needed. Hope for help :]

提交回复
热议问题