Object-C中获取当前触摸点的坐标位置
作者:
yangli | 来源:发表于
2018-08-29 16:26 被阅读0次touches
//当有一个或多个手指触摸事件在当前视图或window窗体中响应
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject]; //视图中的所有对象
CGPoint point = [touch locationInView:self.view]; //返回触摸点在视图中的当前坐标
int x = point.x;
int y = point.y;
NSLog(@"touch (x, y) is (%d, %d)", x, y);
}
UITapGestureRecognizer 获取点击位置
-(void)handleSingleTap:(UITapGestureRecognizer *)sender
{
CGPoint touchPoint = [sender locationInView:self.view];
}
本文标题:Object-C中获取当前触摸点的坐标位置
本文链接:https://www.haomeiwen.com/subject/vzrkwftx.html
网友评论