I have created a number of UIButton
in my iOS
application using the interface builder. Each UIButton
also has its own image (no title).
I would like to increase the size of the button without disturbing the image size inside of it (making the touch-area bigger without changing the image size).
Is this possible to do using the interface builder? I have played around with pretty much every option in the button page but have not find anything yet?
found the answer finally here
In Xcode 8 the button content/title/image
insets have moved to the Size Inspector tab but we all know that and it's still not working, but there is one more step in the alignment in the below image
You need to set button's height and width as per require (if autolayout enable) . it should be larger than image size .
And now set button's contentEdges :
button.contentEdgeInsets = UIEdgeInsetsMake(15, 20, 10, 10); //Change x,y,width,height as per your requirement.
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