ios - UIButton tintColor for disabled and enabled state? -




i have custom class inherits uibutton. thing want accomplish setting tintcolor property based on button's enabled state (i.e enabled or disabled).

is there way achieve that?

this class:

class buttonspostmenu: uibutton {     override func awakefromnib()     {         titlelabel?.font = uifont(name: font_avenirnext_medium, size: 14)         tintcolor = uicolor.white     } } 

you override isenabled property achieve that. tintcolor automatically changed according button's isenabled status:

class buttonspostmenu:uibutton {      //......      override var isenabled: bool {         didset{             if self.isenabled {                 self.tintcolor = uicolor.white             }             else{                 self.tintcolor = uicolor.gray             }         }     }      //......  } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -