首页 > 代码库 > iOS 获取当前点击的坐标

iOS 获取当前点击的坐标

 

 1 - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 2  3 { 4     NSSet *allTouch = [event allTouches]; 5     UITouch *touch = [allTouch anyObject]; 6     CGPoint point = [touch locationInView:[touch view]]; 7     int x = point.x; 8     int y = point.y; 9     NSLog(@"x,y == (%d, %d)", x, y);10 }

 

iOS 获取当前点击的坐标