先看下效果:
点击后:
实现:在页面拖一个button,然后在所在页面声明其变量和一个点击事件
声明:
@IBOutlet weak var BtnZiDong: UIButton!
点击事件函数:
@IBAction func actionZiDong(sender: AnyObject) {
BtnZiDong .setImage(UIImage(named: "check1.png"), forState:UIControlState.Normal)
BtnZiDong .setImage(UIImage(named: "check.png"), forState: UIControlState.Selected) if BtnZiDong .selected == true{
BtnZiDong .selected=false
}else{
BtnZiDong .selected = true
} }