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
Post a Comment