Disabled UIButton not faded or grey

后端 未结 19 1611
死守一世寂寞
死守一世寂寞 2020-12-04 16:11

In my iPhone app, I have a UIButton which I have created in Interface Builder. I can successfully enable and disable it like this in my code ...

sendButton.e         


        
19条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 16:35

    Set title color for different states:

    @IBOutlet weak var loginButton: UIButton! {
            didSet {
                loginButton.setTitleColor(UIColor.init(white: 1, alpha: 0.3), for: .disabled)
                loginButton.setTitleColor(UIColor.init(white: 1, alpha: 1), for: .normal)
            }
        }
    

    Usage: (text color will get change automatically)

    loginButton.isEnabled = false
    

提交回复
热议问题