I'm adding an extension
to UIButton
so that it changes it border color when disabled/enabled
extension UIButton {
override public var enabled: Bool {
didSet {
if enabled {
changeBorderColorForEnabled()
} else {
changeBorderColorForDisabled()
}
}
}
}
The issue is that sometimes the border color changes, but the title color doesn't.
Specifically, it happens when it changes too fast, like in the following piece of code, when it executes line //==== 1. =====//
and //==== 2. =====//
// Enabled by default
self.priceButton.enabled = true //==== 1. =====//
if bought {
self.priceButton.setTitle("bought", forState: UIControlState.Normal)
} else {
if let price = self.product?.price {
self.priceButton.setTitle("Buy for \(price)", forState: UIControlState.Normal)
} else {
// Disable if price hasn't been retrieved
self.priceButton.enabled = false //==== 2. =====//
}
}
How can I fix this?