I have made a button by using PaintCodes code:
class AddIconView: OUIButton {
override func draw(_ rect: CGRect) {
AddIcon.draw(frame: rect)
}
}
Then I add its class to a UIButton. The problem is, the button is not highlighted anymore after touch it, what is the best way to add a highlight to it? for example for this button:
@IBOutlet weak var addButton: AddIconView!
Thank you so much for your help in advance
Edit:
I created a custom class for it:
class OUIButton: UIButton {
override var isHighlighted: Bool {
get {
return super.isHighlighted
}
set {
if newValue {
backgroundColor = .green
}
else {
backgroundColor = .blue
}
super.isHighlighted = newValue
}
}}
For the test, I added a blue and green color. With this code, when I touch the button the background will become and stay blue. I want it to change only when it is touched and after release, it comes back to the normal state, exactly like a normal UIbutton