响应者链

http://www.cnblogs.com/snake-hand/p/3178070.html

重写 hitTest:t withEvent:
// 判断点在不在按钮上面
CGPoint childPoint = [self convertPoint:point toView:childView];

   - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
__block UIView *fitView = nil;
// 遍历子控件
[self.subviews enumerateObjectsUsingBlock:^(UIView *childView, NSUInteger idx, BOOL *stop) {
    if ([childView isKindOfClass:[UIButton class]]) {
        // 判断点在不在按钮上面
        CGPoint childPoint = [self convertPoint:point toView:childView];
        fitView = [childView hitTest:childPoint withEvent:event];
        //            if (fitView)
        NSLog(@"%@",fitView);
    }
}];
if (fitView == nil) {
    fitView = self;
}
return fitView;
}
响应者链_第1张图片
Paste_Image.png

你可能感兴趣的:(响应者链)