ECSlidingViewController

ECSlidingViewController

我想基于https://github.com/ECSlidingViewController/ECSlidingViewController构建一些特殊的动画。

缩放动画类似于下图。

我只想通过PI / 4旋转主视图控制器。如下图所示。

我曾尝试像下面的代码那样对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);
}

任何帮助,指针或示例代码片段都将不胜感激!

最佳答案

我设法做到了。从ECSlidingViewController中给出的缩放动画代码中,不要在

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

通过注释MEZoomAnimationScaleFactor

然后在- (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);
}

享受你的动画:)

10-05 19:56