How to set the action for a UIBarButtonItem in Swift

前端 未结 5 2121
余生分开走
余生分开走 2020-12-12 19:51

How can the action for a custom UIBarButtonItem in Swift be set?

The following code successfully places the button in the navigation bar:

var b = UIB         


        
5条回答
  •  再見小時候
    2020-12-12 20:43

    Swift 4/5 example

    button.target = self
    button.action = #selector(buttonClicked(sender:))
    
    @objc func buttonClicked(sender: UIBarButtonItem) {
            
    }
    

提交回复
热议问题