2012-09-21 46 views
0

我正在處理圖像編輯應用程序(調整大小,旋轉,3d變換)。如果我旋轉圖像然後進行3D變換。它的初始圖像。否則,我改變3D變換,然後旋轉,它也進入初始狀態。如何使圖像旋轉和3D變換同時進行?

對於圖像3D變換我使用下面的代碼:

- (void)moveImage:(UIPanGestureRecognizer *)recognizer 
{ 
     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.0; 
      rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, - self.xTranslation/50.0 * M_PI/180.0f, 0.0f, 1.0f, 0.0f); 
      layer.transform = rotationAndPerspectiveTransform; 
      rotationAndPerspectiveTransform.m34 = - 1.0/500.0; 
      rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, - self.yTranslation/50.0 * M_PI/180.0f, 1.0f, 0.0f, 0.0f); 
      layer.transform = rotationAndPerspectiveTransform; 
     } 
} 

對於我使用下面的代碼圖像旋轉:

- (void)rotateImage:(UIRotationGestureRecognizer *)recognizer 
{ 
    if (state == RSImageViewStateResizing) { 
     recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, recognizer.rotation); 
     recognizer.rotation = 0; 
    } 
} 

如何解決這個問題。隨時歡迎您的建議,示例代碼,示例項目,任何App商店應用程序。提前致謝。任何人都可以幫助我。

+0

任何一個可以幫助我...我是在危急情況.. – Mani

回答

0

使用CAAnimationGroup多個動畫組合成一個

CAAnimationGroup *theGroup = [CAAnimationGroup animation]; 
theGroup.animations=[NSArray arrayWithObject:resizeAnimation, rotationAnimation, 3d transformAnimation];// add here your CAAnimation reference and CATransform3D reference 
[layer addAnimation:theGroup forKey:@"animatePosition"]; 
+0

感謝您的幫助......你能不能說說CAAnimationGroup解釋......我不適用於CAAnimationGroup。 – Mani