By limiting the tangible area in UIButton on the iPhone?

I have three custom buttons with non-rectangular images close to each other, in my opinion. Then I have a problem with the tangible area of ​​each button superimposed on the other buttons. So, how can I limit the tangible area of ​​each button to get the appropriate action?

+5
source share
3 answers

You can overwrite -pointInside:withEvent:which will be used internally for impact testing.

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

+6
source

. A UIImageView UIButton .

+3

You must create custom type buttons and add the necessary images for each using this code:

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];
[btn setFrame:frame];

Creating buttons with images in this way will not overlap image problems.

+3
source

All Articles