ios代碼中添加一個旋轉的收拾識別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是指的哪個值,因為這裡應該是有兩個手指touch屏幕。
locationInView
:返回的是兩個觸摸點中間的位置。如果你需要獲取每個觸摸點的位置,使用locationOfTouch:inView
。
關於它的文檔說明:鏈接。