Disabled UIButton not faded or grey

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

    Maybe you can subclass your button and override your isEnabled variable. The advantage is that you can reuse in multiple places.

    override var isEnabled: Bool {
         didSet {
             if isEnabled {
                 self.alpha = 1
             } else {
                 self.alpha = 0.2
             }
         }
     }
    

提交回复
热议问题