How to make convenient touch handler for UIButton in iOS
Issue #308
If you don’t want to use https://github.com/onmyway133/EasyClosure yet, it’s easy to roll out a closure based UIButton. The cool thing about closure is it captures variables
| 1 | final class ClosureButton: UIButton { | 
Then in cellForItem
| 1 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | 
With this we can even forward touch event to another button
| 1 | func forwardTouchEvent(button: ClosureButton) { | 
Another benefit is that we can apply debouncing to avoid successive tap on button
| 1 | let debouncer = Debouncer(timeInterval: 0.2) |