- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
for (UIView *p in self.subviews){
CGRect frame = p.frame;
if (point.x > frame.origin.x && point.x < frame.origin.x+frame.size.width&&
point.y > frame.origin.y && point.y < frame.origin.y+frame.size.height) {
return p;
}
}
return nil;
}
自定义控件重写这个方法,系统控件用category。