사용자의 터치를 사용하여 회전 및/또는 크기 조정 된 UIView를 변환하려고합니다. 나는 또한 사용자 입력으로 번역하려고합니다.회전 후 UIView 변환
- (void)handleObjectMove:(UIPanGestureRecognizer *)recognizer
{
static CGPoint lastPoint;
UIView *moveView = [recognizer view];
CGPoint newCoord = [recognizer locationInView:playArea];
// Check if this is the first touch
if([recognizer state]==UIGestureRecognizerStateBegan)
{
// Store the initial touch so when we change positions we do not snap
lastPoint = newCoord;
}
// Create the frame offsets to use our finger position in the view.
float dX = newCoord.x;
float dY = newCoord.y;
dX-=lastPoint.x;
dY-=lastPoint.y;
// Figure out the translation based on how we are scaled
CGAffineTransform transform = [moveView transform];
CGFloat xScale = transform.a;
CGFloat yScale = transform.d;
dX/=xScale;
dY/=yScale;
lastPoint = newCoord;
[moveView setTransform:CGAffineTransformTranslate(transform, dX, dY)];
[recognizer setTranslation:CGPointZero inView:playArea];
}
그러나 내가 터치하고 이동하면 모든 다른 이상한 방식으로 번역됩니다. 회전 값을 사용하여 일종의 공식을 적용하여 올바르게 변환 할 수 있습니까?
, 당신은 서로 회전 및/또는 스케일이 인식기에서 번역을 결합하려는 제스처 인식기 (예 : UIPinchGestureRecognizer)? – 4bar
맞습니다. UIView는 번역 전에 사용자 입력에 의해 회전 및/또는 크기 조정되었습니다. 그래서 회전/스케일링을 유지하고 변환해야합니다. –