3

UIViewAnimationTransitionFlipFromRight (및 왼쪽)을 다시 만들려고합니다. 아래에 나와있는 것처럼 이렇게하는 이유는 애니메이션이 방해받는 AVCaptureVideoPreviewLayer를 변경하는 것입니다. UIViewAnimationTransitionFlipFromRight를 사용하면 애니메이션을 반쯤 멈추고 세션을 변경하고 계속 진행할 수 없으므로 여기에 최선의 결과가됩니다.CATransform3D를 사용하여 플립 애니메이션 만들기

이 기능은 작동하지만 UIViewAnimationTransitionFlipFromRight와는 다릅니다. 레이어가 회전하기 시작하지만 슬라이드의 더 많은 부분, 뒤로, 대각선으로 (매우 설명하기가 어렵습니다.) 애니메이션의 두 번째 부분을 위해 되돌립니다. 레이어의 오른쪽을 뒤에서 뒤집기 위해 찾고 왼쪽에서 계속합니다. 대신, 오른쪽은 오른쪽에서 시작하여 뒤쪽으로 회전 한 다음 다시 오른쪽으로 회전합니다.

내가 뭘 잘못하고 있니?

업데이트 : 처음 제대로 회전합니다. 그 후, 위에 언급 된 문제가 계속됩니다. 재설정해야하는 AVCaptureVideoPreviewLayer와 관련이 있습니까? 확실하지 않습니다. 단지 추측입니다.

[UIView animateWithDuration:1.5 delay:0.0 
           options:UIViewAnimationCurveEaseIn 
          animations:^{ 
           CATransform3D frontTransform = CATransform3DIdentity; 
           frontTransform.m34 = 1.0/-850.0; 
            frontTransform = CATransform3DMakeRotation(M_PI_2,0.0,1.0,0.0); //flip halfway 
            frontTransform = CATransform3DScale(frontTransform, 0.835, 0.835, 0.835); 
           previewLayer.transform = frontTransform; 

          } 
          completion:^(BOOL finished){ 
           if (finished) { 

            [previewLayer setAutomaticallyAdjustsMirroring:NO]; 
            [previewLayer setMirrored:NO]; 

            [session beginConfiguration]; 
            [[self captureManager] setMirroringMode:AVCamMirroringOff]; 
            [session commitConfiguration]; 

            [UIView animateWithDuration:1.5 
                  delay:0.0 
                 options:UIViewAnimationCurveEaseOut 
                 animations:^{ 
                  CATransform3D backTransform = CATransform3DIdentity; 
                  backTransform.m34 = 0.0f; 
                   backTransform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0); //finish the flip 
                   backTransform = CATransform3DScale(backTransform, 1.0, 1.0, 1.0); 
                  previewLayer.transform = backTransform; 
                 } 
                 completion:^(BOOL finished){ 
                   //nothing upon completion 
                 } 
             ]; 
           } 
          } 
      ]; 

답변

1

"UIViewAnimationTransitionFlipFromRight와 (과) 똑같지 않다"는 말은 아닙니다. 당신은 원근법을보고 있는가? 원근법을 얻기 위해 먼저 CATransform3D 함수를 호출하기 전에 먼저 .m34 필드를 지정해야한다는 것을 알았습니다. 변환을 선언하고 CATransform3DMakeRotation을 호출하기 직전에이를 설정하십시오.

+0

나는 그것을 분명히 시도 할 것이다. 내 부분에 대한 감독, 나는 OP를 업데이 트됩니다. –

+0

나는 처음으로 그것을 부를 때 정확한 애니메이션을하는 것처럼 보였지만, 매번 애니메이션을 반쯤하고 역전시킨다. –

0

애니메이션을 완성 할 때 previewLayer.transform을 CATransform3DIdentity로 재설정해야합니다. 그것은 당신이 당신이 그것을 두 번째로 실행했을 때 이상한 반대의 행동을 보는 이유 일 수 있습니다.

관련 문제