Increasing the tap area of a UIButton
The other day, Soroush wrote a great post about hitTest(_:with:) (you should check it out), which reminded me of a problem I solved the other week: I wanted to increase a UIButton’s tap area, without increasing the button’s frame.
The following code would go in one of the button’s superviews; for example, you might have a mainContainer, which has a UIStackView that contains the button — we’d implement it in mainContainer: