Button doesn't use .Normal attributes in .Disabled state when they're not explicitly set
avf opened this issue · comments
You can reproduce this by adding the following line to the sample project:
let awesomeButton = SimpleButton.buttonWithType(.Custom) as! SimpleButton
awesomeButton.enabled = false //add this
If you run the project with that line in place, you will see that the awesomButton is not visible. Its attributes are set properly, but it hasn't been updated visually.
The problem is caused by the following check:
if state == self.state
When you call e.g. setBackgroundColor
, and button's state is .Disabled, but the attributes are set for .Normal. Thus, the method changeBackgroundColorForStateChange
is not called and the button's appearance is not updated.
I wasn't sure if the above check is needed for performance reasons or if you can just get rid it.