0

How to increase tapable (hitting) area of (custom Type) UIButton without increasing size of background image

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Mano
  • 21
  • 2
  • 5
  • Just two possibilities: either make a custom view or make the background invisible and really big. – Arc676 Dec 04 '15 at 13:41
  • Also see http://stackoverflow.com/questions/12297467/how-to-expand-the-hittest-area-of-a-uibutton-without-extruding-its-background-i and http://stackoverflow.com/questions/13246452/how-to-increase-tapable-hitting-area-of-custom-type-uibutton-without-increas?rq=1 – rmaddy Dec 04 '15 at 16:18
  • Please make some attempt to search before posting a question. – rmaddy Dec 04 '15 at 16:19

2 Answers2

2

The simplest way - change contentEdgeInsets property value

button.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
Igor
  • 1,537
  • 10
  • 12
1

if you are using icons to set in UIbutton. Then use image with 3 sizes.Like

  xyz.png
  xyz@2x.png
  xyz@3x.png

and set image xyz.png in image field not in background image.Then increase size of button.It will increase size of button not image size.

TheEye
  • 9,280
  • 2
  • 42
  • 58
Anil solanki
  • 962
  • 4
  • 20