简单说明:
- 通过判断当前点击的point是否在某个view的layer中来判断点击是在哪个view中
代码
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
CGPoint point = [[touches anyObject] locationInView:self.view];
point = [self.subView1.layer convertPoint:point fromLayer:self.view.layer];
if ([self.subView1.layer containsPoint:point]) {
//处理点击到这个view中要执行的事件
return;
}
}