UIButton

作者: CaptainRoy | 来源:发表于2019-07-15 02:24 被阅读0次
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let button = UIButton(type: .custom)
        button.frame = CGRect(x: 100.0, y: 100.0, width: 100.0, height: 50.0)
        button.setTitle("按钮", for: .normal)
        button.backgroundColor = UIColor.red
        button.addTarget(self, action: #selector(buttonClickAction(button:)), for: .touchUpInside)
        self.view.addSubview(button)
        
    }
    
    @objc func buttonClickAction(button:UIButton) -> Void {
        button.isEnabled = false
        button.setTitle("完成", for: .normal)
        print("点击了")
    }

}

相关文章

网友评论

      本文标题:UIButton

      本文链接:https://www.haomeiwen.com/subject/qnowkctx.html