gpt4 book ai didi

ios - 查看动画后发生的转换

转载 作者:行者123 更新时间:2023-11-29 13:01:31 25 4
gpt4 key购买 nike

我有一个已旋转的 View :

self.mainView.layer.transform = CATransform3DRotate(self.mainView.layer.transform, -M_PI / 2, 0, 0, 1);

我对其应用了 CAKeyFrameAnimation:

    CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
bounceAnimation.fillMode = kCAFillModeBoth;
bounceAnimation.removedOnCompletion = YES;
bounceAnimation.duration = 0.4;
bounceAnimation.values = @[
//[NSValue valueWithCATransform3D:CATransform3DMakeRotation(-M_PI / 2.0f, 0.0f, 0.0f, 1.0f)]
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 0.01f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.1f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 0.9f)],
[NSValue valueWithCATransform3D:CATransform3DIdentity]];
bounceAnimation.keyTimes = @[@0.0f, @0.5f, @0.75f, @1.0f];
bounceAnimation.timingFunctions = @[
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[self.mainView.layer addAnimation:bounceAnimation forKey:@"bounce"];

当我将 View 附加到它的父 View 时,动画应用到 View BEFORE 我的初始旋转应用到它,动画完成后,然后应用旋转。

我将如何着手制作它以便在动画发生之前应用我发布的第一位代码的旋转?那么当 View 附加到它的父 View 时,它已经出现旋转,然后进行动画?

最佳答案

您的参数实际上将设置转换值,因此您需要使用您想要的组合转换。

您应该像这样将旋转与 transform3D 结合起来:

CATransform3D tranform1 = CATransform3DMakeScale(0.01f, 0.01f, 0.01f);
transform1 = CATransform3DRotate(transform1, -m_PI / 2.0f, 0.0f, 0.0f, 1.0f);
CATransform3D tranform2 = CATransform3DMakeScale(1.1f, 1.1f, 1.1f);
transform2 = CATransform3DRotate(transform2, -m_PI / 2.0f, 0.0f, 0.0f, 1.0f);
CATransform3D tranform3 = CATransform3DMakeScale(0.9f, 0.9f, 0.9f);
transform3 = CATransform3DRotate(transform3, -m_PI / 2.0f, 0.0f, 0.0f, 1.0f);

bounceAnimation.values = @[
[NSValue valueWithCATransform3D:transform1],
[NSValue valueWithCATransform3D:transform2],
[NSValue valueWithCATransform3D:transform3]];

关于ios - 查看动画后发生的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19673048/

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