CATransform3D无法正常工作,我使用下面的代码。我的问题是如果我改变变换它的工作正常。一旦我松开手指然后进行更多变换,图像就会转到初始图像。如何设置最后一次转换?我正在使用PanGesture进行转换。请给出一些想法。提前谢谢。
if ([recognizer respondsToSelector:@selector(translationInView:)]) {
CGPoint translation = [(UIPanGestureRecognizer *)recognizer translationInView:recognizer.view.superview];
CALayer *layer = self.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, translation.x * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
rotationAndPerspectiveTransform.m34 = 1.0 / -500;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, -translation.y * M_PI / 180.0f, 1.0f, 0.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
}
答案 0 :(得分:0)
CATransform3DIdentity
表示每次视图接触时重置转换。请改用CATransform3D rotationAndPerspectiveTransform = layer.transform;
。