@implementation TempView
{
BOOL isSelfTouche;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(isSelfTouche)
[self removeFromSuperview];
}
#pragma mark - hitTest
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *touchedView = [super hitTest:point withEvent:event];
if(!touchedView)
{
NSLog(@"hitTest:touchedView == nil");
return nil;
}
//NSLog(@"%@ tag:%d",[touchedView class], [touchedView tag]);
//if(touchedView.tag == 1234)return self;
isSelfTouche = NO;
//if([touchedView isMemberOfClass:[TempView class]])
if(touchedView == self)isSelfTouche = YES;
return touchedView;
}
@end
hitTest:withEvent:截获子视图消息
最新推荐文章于 2022-06-07 21:22:38 发布