How to make a section of my UIView a clickable area
3 answers
Add UITapGestureRecognizer
to yours UIView
. When you receive the tap, check your recognizer locationInView:
. Run the action if a tap has occurred in an area that you want to make sensitive to paint; otherwise, ignore the click event.
0
source to share
Add a custom UIButton of your opinion, which is always needed for clickability, then take action on it.
UIButton *button = [UIButton buttonWithType:0];
[button setFrame:CGRectmake(0,0,0,0)]; //What ever clickable area, provide here
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
+3
user2028616
source
to share