📜  ios UIButton 更改图像 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:13.800000             🧑  作者: Mango

代码示例1
var bRec:Bool = true

@IBOutlet weak var btnRec: UIButton!
@IBAction func btnRec(_ sender: Any) {
    bRec = !bRec
    if bRec {
        btnRec.setImage(UIImage(named: "MicOn.png"), for: .normal)
    } else {
        btnRec.setImage(UIImage(named: "MicOff.png"), for: .normal)
    }
}