我正在使用UIRotationGestureRecognizer,并且在target方法中有以下代码:

if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
    UIView *piece = gestureRecognizer.view;
    CGPoint locationInView = [gestureRecognizer locationInView:piece];
    CGPoint locationInSuperview = [gestureRecognizer locationInView:piece.superview];

    piece.layer.anchorPoint = CGPointMake(locationInView.x / piece.bounds.size.width, locationInView.y / piece.bounds.size.height);
    piece.center = locationInSuperview;
}

但是我不太了解locationInView:返回值指示哪个值,因为应该有两个手指触摸屏幕。

最佳答案

locationInView:方法返回两次触摸的中心点。如果您想知道两个单独触摸的位置,请使用locationOfTouch:inView:

10-08 09:28