I use UIButton
with auto layout. When images are small the tap area is also small. I could imagine several approaches to fix this:
Beside the two approaches above is there a better solution to increase the tap area of a UIButton?
A control that executes your custom code in response to user interactions.
Programmatically. To make a multi-line text in UIButton, you insert a new line character ( \n ) wherever you want in button title and set lineBreakMode to byWordWrapping . You can adjust text alignment with . textAlignment .
You can simply adjust the content inset of the button to get your desired size. In code, it will look like this:
button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16) //Or if you specifically want to adjust around the image, instead use button.imageEdgeInsets
In interface builder, it will look like this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With