Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

limiting the touchable area in a UIButton in IPhone?

I have three custom buttons with non-rectangular images close to each other in my view. Then I have a problem with touchable area's of each button overlap with other buttons. So how can I limit the touchable area of each buttons to get the corresponding actions?

like image 616
hacker Avatar asked Dec 28 '11 13:12

hacker


2 Answers

You can overwrite -pointInside:withEvent:, that internally will be used for hit testing.

A nice project using this technique is OBShapedButton, where transparent pixel will not trigger a hit.

like image 159
vikingosegundo Avatar answered Sep 28 '22 05:09

vikingosegundo


Use two components. A UIImageView with a smaller UIButton on top.

like image 45
Peter DeWeese Avatar answered Sep 28 '22 06:09

Peter DeWeese