How to programmatically set action for barButtonItem in swift 3?

后端 未结 12 1590
鱼传尺愫
鱼传尺愫 2020-12-23 16:17

Here is what I used previously,

var barButtonItem = UIBarButtonItem(image: backImgs, style: UIBarButtonItemStyle.plain, target: self, action: Selector(\"menu         


        
12条回答
  •  情书的邮戳
    2020-12-23 16:38

    One line of code on Swift 3 for iOS 10.1:

    navigationController?.navigationBar.topItem?.rightBarButtonItem = UIBarButtonItem(title: "Add", style: .plain, target: self, action: nil)
    

提交回复
热议问题