3

How can I make the area of a UIButton in which the button still triggers the touchUpInside method smaller? When I press a button and drag my finger outside it (not lifting the finger), the area outside the button's bounds that keeps the button highlighted is pretty large.

I would like to achieve that the touchUpInside method would only get triggered if the finger (being dragged) is still inside the bounds of the button. Currently, if you press a button and, while not lifting your finger, you drag your finger outside the button, the area in which the touchUpInside method (instead of the touchUpOutside method) is called is pretty big. Can I limit the touchUpInside method to get called only if the finger is inside the bounds of the button?

Thank you.

neja
  • 378
  • 2
  • 8

1 Answers1

0

I'm not pretty sure if I clearly understand your problem. So I would like to provide my 2 solutions:

  1. The tricky one: you add another smaller subview to the button which being dragged, you turn off userInteraction of this button and reactivate it when you're done dragging.

  2. Disable userInteraction for the stable button, you recognise if the two buttons touch each others base on their frame. Reactive userInteraction when you're done just like above.

Thanh-Nhon Nguyen
  • 3,402
  • 3
  • 28
  • 41
  • Thanks for your answer. What good would it do to add a subview to a button? I need to register a 'tap and hold' on a button, so the touchUpOutside method will be called. As for no. 2: The buttons are not touching each other nor they ever will - I'm not dragging one button over the other. I'll try to make my question more clearer. I guess I've over complicated it. – neja May 01 '14 at 12:13