我对 UIGestures 很熟悉,但这种特殊的需求让我碰壁了。
问题:如何找到 UIPinchGesture 的起点和终点?
我必须得到所有这四个点,并且必须在服务器端进行一些计算。
以前有人试过吗?
我对 UIGestures 很熟悉,但这种特殊的需求让我碰壁了。
问题:如何找到 UIPinchGesture 的起点和终点?
我必须得到所有这四个点,并且必须在服务器端进行一些计算。
以前有人试过吗?
利用
- (CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view
喜欢
[gesture locationOfTouch:0 inView:youView]; //first
[gesture locationOfTouch:1 inView:youView]; //second
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touchPositionOne = [[[event allTouches] allObjects] objectAtIndex:0];
UITouch *touchPositionTwo = [[[event allTouches] allObjects] objectAtIndex:1];
CGPoint fps = [touchPositionOne locationInView:self.imageView];
CGPoint sps = [touchPositionTwo locationInView:self.imageView];
NSLog(@"%@ %@", NSStringFromCGPoint(fps), NSStringFromCGPoint(sps));
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touchPositionOne = [[[event allTouches] allObjects] objectAtIndex:0];
UITouch *touchPositionTwo = [[[event allTouches] allObjects] objectAtIndex:1];
CGPoint fps = [touchPositionOne locationInView:self.imageView];
CGPoint sps = [touchPositionTwo locationInView:self.imageView];
NSLog(@"%@ %@", NSStringFromCGPoint(fps), NSStringFromCGPoint(sps));
}
CGPoint point1 = [gestureRecognizer locationOfTouch:0 inView:piece];
CGPoint point2 = [gestureRecognizer locationOfTouch:1 inView:piece];
CGPoint center = [gestureRecognizer locationInView:piece];
我认为在 XCode 12 中您可以使用 location(ofTouch:, in:) 来识别点的位置:
print(sender.location(ofTouch: 0, in: view))
print(sender.location(ofTouch: 1, in: view))