gpt4 book ai didi

ios - 我如何在 iOS 中为 ECSlidingViewController 构建 3D 转换?

转载 作者:行者123 更新时间:2023-11-29 12:42:06 25 4
gpt4 key购买 nike

我想建立一些特殊的动画基础 https://github.com/ECSlidingViewController/ECSlidingViewController .

缩放动画如下图。

enter image description here

我只想将主视图 Controller 旋转 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);
}

非常感谢任何帮助、指示或示例代码片段!

最佳答案

我成功了。从 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);
}

享受你的动画:)

关于ios - 我如何在 iOS 中为 ECSlidingViewController 构建 3D 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24606372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com