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]; } }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM