2

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;
}
4

1 回答 1

1

CATransform3DIdentity意味着每次您的视图收到触摸时都会重置转换。改为使用CATransform3D rotationAndPerspectiveTransform = layer.transform;

于 2012-09-17T13:30:34.243 回答