How to use addTarget method in swift 3

后端 未结 10 1410
清酒与你
清酒与你 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:56

      let button: UIButton = UIButton()
        button.setImage(UIImage(named:"imagename"), for: .normal)
        button.addTarget(self, action:#selector(YourClassName.backAction(_sender:)), for: .touchUpInside)
    
        button.frame = CGRect.init(x: 5, y: 100, width: 45, height: 45)
        view.addSubview(button)
    
        @objc public func backAction(_sender: UIButton) {
    
        }
    

提交回复
热议问题