Swift 4.0 按鈕
阿新 • • 發佈:2018-12-12
//按鈕位置 let button:UIButton=UIButton(frame:CGRect(x: self.view.frame.width/2-60, y: 64+60, width: 120, height: 120)) //按鈕背景顏色 button.backgroundColor=UIColor.red //按鈕設定圓角 button.layer.masksToBounds=true button.layer.cornerRadius=13 //按鈕插入背景圖片 button.setBackgroundImage(UIImage(named: "2.jpg"), for: UIControl.State.normal) //按鈕點選方法 button.addTarget(self, action: #selector(click), for: .touchUpInside)
按鈕的點選放生時間
@objc func click(){
// let tag = sender.tag
print("哈哈哈")
}