Domanda

CATransform3D not working properly, I am using the below code. My problem is If I change the transform Its working fine. Once I release my finger and then make more transform the image goes to the Initial image. How to set the last transform? I am using PanGesture for the transform. Please give some Idea. Thanks in advance.

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;
}
È stato utile?

Soluzione

CATransform3DIdentity means you resetting the transformation every time your view receives touch. Use CATransform3D rotationAndPerspectiveTransform = layer.transform; instead.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top