How do I show/hide a UIBarButtonItem?

前端 未结 30 2312
执念已碎
执念已碎 2020-11-28 01:18

I created a toolbar in IB with several buttons. I would like to be able to hide/show one of the buttons depending on the state of the data in the main window.

30条回答
  •  佛祖请我去吃肉
    2020-11-28 01:50

    If you are using Swift 3

    if (ShowCondition){
       self.navigationItem.rightBarButtonItem = self.addAsset_btn 
     } 
    else {
       self.navigationItem.rightBarButtonItem = nil
     }
    

提交回复
热议问题