Reputation: 306
I'm trying to make the hit area of a UIButton larger.
I tried using:
myButton.setHitTestEdgeInsects
but Xcode doesn't recognise it.
I also tried:
myButton.contentEdgeInsets = (UIEdgeInsetsMake(5, 5, 5, 5))
but it changes the look of my button.
Im using swift so for I added the necessary files to the import header. i guess the problem is there. Can someone help with that or tell about a similar swift function? here is the func im trying to use -
Edit - I think i'm getting closer to the solution because im writing in swift xcode recognised it like that
myButton.hitTestEdgeInsets = UIEdgeInsetsMake(-200, -200, -200, -200)
instead of -
myButton.setHitTestEdgeInsets = UIEdgeInsetsMake(-200, -200, -200, -200)
so now xcode recognises it but still i have no change in my hit area..
Upvotes: 0
Views: 2222
Reputation: 1377
Why did you simple create a custom button which are at the size you want for your hit box but include a margin inside it's content ?
Or may be with a UIEdgeInsets
put on your button, your button will have a margin so the hit box seems bigger than button with this solution..
Upvotes: 2