I have a custom cell with a few UIButtons in it. I have created Target Actions like so on the buttons:
[cell.customLocationButton addTarget:self action:@selector
I've been searching all over the internet and finally I've found a solution from a post on StackOverFlow check it out here.
For Swift 4 You can add this UIButton extension and it will work fine.
extension UIButton {
override open func touchesBegan(_ touches: Set, with event: UIEvent?) {
isHighlighted = true
super.touchesBegan(touches, with: event)
}
override open func touchesEnded(_ touches: Set, with event: UIEvent?) {
isHighlighted = false
super.touchesEnded(touches, with: event)
}
override open func touchesCancelled(_ touches: Set, with event: UIEvent?) {
isHighlighted = false
super.touchesCancelled(touches, with: event)
}
}