Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of the UIButton when its state is .disabled

I'm trying to change the button image color when it's disabled. To mention that my button may be also enabled

The thing is it's always grey.

    sendCodeBtn.isEnabled = false
    sendCodeBtn.setImage(#imageLiteral(resourceName: "validated_phone").withRenderingMode(.alwaysTemplate), for: .disabled)
    sendCodeBtn.tintColor = Theme.defaultColor()
like image 555
Mohamed Lee Avatar asked Oct 20 '25 01:10

Mohamed Lee


1 Answers

@IBAction btn : UIButton!
if btn.state == .isSelected{
    btn.backgroundColor = UIColor.red
}
like image 124
Bhargav Sejpal Avatar answered Oct 21 '25 14:10

Bhargav Sejpal