I have a customized UIButton that I want to redraw after it is clicked -- I want to change its color. Here is the code:
class DayButtons: UIButton {
var isPressed: Bool = false
var color = UIColor.whiteColor()
override func drawRect(rect: CGRect) {
let cornerR = CGFloat(5)
var path = UIBezierPath(roundedRect: rect, cornerRadius: cornerR)
color.setFill()
path.fill()
}
}
Is there way to call drawRect again in my main thread?
You should call setNeedsDisplay()
on your button, which will in turn call drawRect()
for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With