当事件传递到相应的UIResponder后,会首先调用:
hitTest:withEvent: return (UIView *)
UIApplication -> UIWindow
什么时候调用:当事件传递给一个控件的时候就会调用
作用:找最合适的viewhitTest:withEvent: return (UIView *)
1.看窗口是否能接收。 如果不能 return nil; 自己不能接收事件,也不能处理事件,而且也不能把事件传递给子控件。
2.判断点在不在窗口上 如果点在窗口上,意味着窗口满足合适的view
3.白色的view hitTest:withEvent: return nil
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
// 把左边控件上的点转换为右边上边控件的点
// CGPoint buttonPoint = [self convertPoint:point toView:_button];
// 从右边这个view上的点转换为坐标上的点
CGPoint buttonPoint =[_button convertPoint:point fromView:self];
if ([_button pointInside:buttonPoint withEvent:event]) return NO;return [super pointInside:point withEvent:event];
}