How to use addTarget method in swift 3

后端 未结 10 1377
清酒与你
清酒与你 2020-11-29 02:20

here is my button object

    let loginRegisterButton:UIButton = {
    let button = UIButton(type: .system)
    button.backgroundColor = UIColor         


        
10条回答
  •  攒了一身酷
    2020-11-29 02:44

    Try this with Swift 4

    buttonSection.addTarget(self, action: #selector(actionWithParam(_:)), for: .touchUpInside)
    @objc func actionWithParam(sender: UIButton){
        //...
    }
    
    buttonSection.addTarget(self, action: #selector(actionWithoutParam), for: .touchUpInside)
    @objc func actionWithoutParam(){
        //...
    }
    

提交回复
热议问题