UIView不接受触摸事件的三种情况:
1.不接收用户交互
userInteractionEnabled = NO
2.隐藏
hidden = YES
3.透明
alpha = 0.0 ~ 0.01
注意:
1.
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
return NO;
} 也不会接受任何事件(包括子视图)
2.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
return self;
} 事件不会传递到子视图 但是可以通过一下的方式传递给响应者链
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//可以先处理自己的事
[[self nextResponder] touchesEnded:touches withEvent:event];
}