Disabled UIButton not faded or grey

后端 未结 19 1617
死守一世寂寞
死守一世寂寞 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:29

    Create an extension in Swift > 3.0 rather than each button by itself

    extension UIButton {
        override open var isEnabled : Bool {
            willSet{
                if newValue == false {
                    self.setTitleColor(UIColor.gray, for: UIControlState.disabled)
                }
            }
        }
    }
    

提交回复
热议问题