通過添加點擊手勢獲取當前座標

//創建並添加手勢
 UITapGestureRecognizer *tap=[[UITapGestureRecognizerallocinitWithTarget:self action:@selector(tapp:)];
[UIView addGestureRecognizer:tap];
//實現代理方法
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer
{
   
return YES;
}
//實現觸發事件
-(void)tapp:(UITapGestureRecognizer*)sender
{
   CGPoint point = [sender locationInView:rightView];
   NSLog(@"handleSingleTap!pointx:%f,y:%f",point.x,point.y);
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章