-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
int count = (int)self.subviews.count;
for (int i=count-1; i>=0; i--) {
UIView *subView = self.subviews[i];
// 点击事件作用在子控件上面, 返回点击点
CGPoint isPoint = [self convertPoint:point toView:subView];
// 获取到被点击的视图
UIView *aView = [subView hitTest:isPoint withEvent:event];
if (aView) {
return aView;
}
}
return self;
}
网友评论