0

I would like to have a small rounded UIButton with background. but increased tabbing arrea

enter image description here

Background is not an image, but a bacground color + layer.cornerRadius.

I have checked inserts, but not sure I can sort it out with background...and I don't wont to increase the size of the app, by using images

enter image description here

The problem is only with increased tabbing arrea. I know how to set button background and rounded corners. Any advices would be appreciated

andrii
  • 727
  • 3
  • 9
  • 21

2 Answers2

1

Just override hitTest and you'll be fine. You can read more about this on Apple docs and this SO answer.

Guilherme Matuella
  • 2,193
  • 1
  • 17
  • 32
0

Background is not an image, but a bacground color + layer.cornerRadius

Well, that's the problem. You cannot make a button magically "feel" a tap outside its own boundaries. Your button's boundaries are the boundaries of the red rounded rectangle. A tap outside the red rounded rectangle is therefore outside the button.

If you want the tappable area to be bigger, make the button bigger. If you then want the red rounded rectangle to be smaller than the button, make it an image.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • 2
    _You cannot make a button magically "feel" a tap outside its own boundaries._ Actually, you can. And I'm pretty sure that you've heard (by knowing who you are) about overriding "-hitTest:" method ;) – arturdev Oct 07 '18 at 18:49