📌  相关文章
📜  以编程方式快速创建自定义按钮 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:01:03.054000             🧑  作者: Mango

代码示例2
let button = UIButton(frame: CGRect(x: 20, y: 20, width: 200, height: 60))
 button.setTitle("Email", for: .normal)
 button.backgroundColor = .white
 button.setTitleColor(UIColor.black, for: .normal)
 button.addTarget(self, action: #selector(self.buttonTapped), for: .touchUpInside)
 myView.addSubview(button)



@objc func buttonTapped(sender : UIButton) {
                //Write button action here
            }