标签:ret nta eve nbsp tom uiview cgpoint nat code
BView遮挡AView,BView有子viewB1,AView有手势。希望点击在B1中的时候,AView可以响应手势。
若果让BView整个userInteractionEnabled = NO,那么点击在BView的任何地方,AView的手势都会响应,不符合要求。
可以用一下函数实现
- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event; // default returns YES if point is in bounds
@interface BView () @property (strong, nonatomic) UIView *B1; @end @implementation LYFControlsView ... - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { if ([self.B1 pointInside:[self convertPoint:point toView:self.B1] withEvent:event]) { //如果点击在B1内,就不再传递,让出响应 return NO; } return YES; } @end
标签:ret nta eve nbsp tom uiview cgpoint nat code
原文地址:https://www.cnblogs.com/liuyongfa/p/11044398.html