1

https://github.com/ECSlidingViewController/ECSlidingViewController을 기반으로하는 특수 애니메이션을 제작하고 싶습니다.어떻게 ECSlidingViewController 용 iOS에서 3D 변형을 만들 수 있습니까?

줌 애니메이션은 아래 그림과 같습니다.

enter image description here

는 I 화상은 아래와 같이 PI/(4)에 의해 메인 뷰 컨트롤러를 회전 할.

enter image description here

나는 코드를 아래와 같이 변환 EndState하려고했지만, 그것은 작동하지 않습니다.

- (void)topViewAnchorRightEndState:(UIView *)topView anchoredFrame:(CGRect)anchoredFrame { 

CATransform3D toViewRotationPerspectiveTrans = CATransform3DIdentity; 
toViewRotationPerspectiveTrans.m34 = -0.003; 
toViewRotationPerspectiveTrans = CATransform3DRotate(toViewRotationPerspectiveTrans, M_PI_4, 0.0f, -1.0f, 0.0f); 

topView.layer.transform = toViewRotationPerspectiveTrans; 
topView.layer.position = CGPointMake(anchoredFrame.origin.x + ((topView.layer.bounds.size.width * MEZoomAnimationScaleFactor)/2), topView.layer.position.y); 
} 

모든 도움말, 포인터 또는 예제 코드 스 니펫은 정말 감사하겠습니다!

+0

당신이 작업 얻을 관리 했나 : 같은

[self topViewAnchorRightEndState:topView anchoredFrame:[transitionContext finalFrameForViewController:topViewController]]; 

애니메이션 기능은 이제 볼 것인가? 내가 똑같은 일을하려고 노력하고있어 어떤 도움을 주시면 감사하겠습니다. –

답변

1

나는 그것을 할 수 있었다. ECSlidingViewController에 주어진 줌 애니메이션 코드에서 MEZoomAnimationScaleFactor을 주석으로

- (CGRect)topViewAnchoredRightFrame:(ECSlidingViewController *)slidingViewController{ 
    CGRect frame = slidingViewController.view.bounds; 

    frame.origin.x = slidingViewController.anchorRightRevealAmount; 
    frame.size.width = frame.size.width/* * MEZoomAnimationScaleFactor*/; 
    frame.size.height = frame.size.height/* * MEZoomAnimationScaleFactor*/; 
    frame.origin.y = (slidingViewController.view.bounds.size.height - frame.size.height)/2; 

    return frame; 
} 

에서 줌 배율을 적용하지 않습니다.

다음 - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext 방법의 상단에
[topView.layer setAnchorPoint:CGPointMake(0, 0.5)]; 
[topView.layer setZPosition:100]; 

마지막으로 모든 변환을하는 방법이 있어야합니다 추가 :

- (void)topViewAnchorRightEndState:(UIView *)topView anchoredFrame:(CGRect)anchoredFrame { 
    CATransform3D transform = CATransform3DIdentity; 
    transform.m34 = -0.003; 
    transform = CATransform3DScale(transform, ARDXZoomAnimationScaleFactor, ARDXZoomAnimationScaleFactor, 1); 
    transform = CATransform3DRotate(transform, -M_PI_4, 0.0, 1.0, 0.0); 
    topView.layer.transform = transform; 
    topView.frame = anchoredFrame; 
    topView.layer.position = CGPointMake(anchoredFrame.origin.x, anchoredFrame.size.height/2+anchoredFrame.origin.y); 
} 

는 애니메이션 : ryancrunchi의 대답의 상단에

0

을 즐길 수 , 컨테이너 프레임의 중간이 아니라 x 위치를 0으로 재설정하도록 topViewStartingState를 수정해야합니다. 끝에 육포 왼쪽 메뉴의 원인이되는 애니메이션의 실수도 있습니다

- (void)topViewStartingState:(UIView *)topView containerFrame:(CGRect)containerFrame { 
    topView.layer.transform = CATransform3DIdentity; 
    topView.layer.position = CGPointMake(containerFrame.size.width/2, containerFrame.size.height/2); 
} 

- (void)topViewStartingState:(UIView *)topView containerFrame:(CGRect)containerFrame { 
    topView.layer.transform = CATransform3DIdentity; 
    topView.layer.position = CGPointMake(0, containerFrame.size.height/2); 
} 

변경 :이 애니메이션의 시작 오프셋 육포를 제거 오프닝 애니메이션. 이 실행되도록 애니메이션 동안 애니메이션의 완료 부분에서 다음 줄을 복사

... 
if (self.operation == ECSlidingViewControllerOperationAnchorRight) { 
     [containerView insertSubview:underLeftViewController.view belowSubview:topView]; 
     [topView.layer setAnchorPoint:CGPointMake(0, 0.5)]; 

     [topView.layer setZPosition:100]; 

     [self topViewStartingState:topView containerFrame:containerView.bounds]; 
     [self underLeftViewStartingState:underLeftViewController.view containerFrame:containerView.bounds]; 

     NSTimeInterval duration = [self transitionDuration:transitionContext]; 
     [UIView animateWithDuration:duration animations:^{ 
      [self underLeftViewEndState:underLeftViewController.view]; 
      underLeftViewController.view.frame = [transitionContext finalFrameForViewController:underLeftViewController]; 
      [self topViewAnchorRightEndState:topView anchoredFrame:[transitionContext finalFrameForViewController:topViewController]]; 
     } completion:^(BOOL finished) { 
      if ([transitionContext transitionWasCancelled]) { 
       underLeftViewController.view.frame = [transitionContext finalFrameForViewController:underLeftViewController]; 
       underLeftViewController.view.alpha = 1; 
       [self topViewStartingState:topView containerFrame:containerView.bounds]; 
      } 

      [transitionContext completeTransition:finished]; 
     }]; 
    } 
...