UITapGestureRecognizer的用法
UITapGestureRecognizer *selfViewTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(removeSelfView:)];
[self addGestureRecognizer:selfViewTap];//注意同一个点击手势不能添加到多个视图上
selfViewTap.numberOfTapsRequired = 2;//点击次数
selfViewTap.numberOfTouchesRequired = 2;//手指个数、单击
- (void)removeSelfView:(UITapGestureRecognizer *)selfTap{
CGPoint selectPoint = [selfTap locationInView:self];
NSLog(@"%@",[NSValue valueWithCGPoint:selectPoint]);
//CGRectContainsPoint(CGRect rect, <#CGPoint point#>)判断某个点是否包含在某个CGRect区域内
if(!CGRectContainsPoint(_bg_imageView.frame, selectPoint)){
[self removeFromSuperview];
}
}
感谢您的访问!
若对您有帮助或有兴趣请关注博客:http://www.cnblogs.com/Rong-Shengcom/