- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *view = [super hitTest:point withEvent:event]; if (view == nil) { for (UIView *subView in self.subviews) { CGPoint tp = [subView convertPoint:point fromView:self]; if (CGRectContainsPoint(subView.bounds, tp)) { view = subView; } } } return view; }
不让超出的子视图显示:
@property(nonatomic) BOOL clipsToBounds;