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("点击了")
}
}
网友评论