I have 2 views , but i want to make 1 view (virtually) bigger. if I place my tapGesture on v1, the tap gesture works with a bigger hit area but if I place my tapGesture on
The way you are doing it is possible but difficult to do correctly.
What I recommend is to add the UITapGestureRecognizer
to their common superview and then decide what view is the receiver depending on tap location, e.g.
- (void)onTap:(UITapGestureRecognizer*)tapRecognizer {
CGPoint touchPosition = [tapRecognizer locationInView:self];
CGRect view1Frame = self.view1.frame;
view1Frame.width += 100;
view1Frame.height += 100;
if (CGRectContainsPoint(view1Frame, touchPosition)) {
[self.view1 handleTap];
return;
}
...
}
If the views don't have a common superview, just embed each of them in a bigger transparent view and add the recognizer to this bigger view.