I want to change color of UIView
when it's tap and change it back to it's original color after tap event
I already implemented these 2 methods but their behavior is not giving me required results
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
backgroundColor = UIColor.white
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
backgroundColor = UIColor.gray
}
These 2 methods work but after press tap on UIView
for 2 seconds then it works. Moreover it doesn't change the color of UIView
back to white after pressing it (In short it stays gray until I restart the app)
I am using tap gestures on UIView