gpt4 book ai didi

objective-c - 具有 2 个步骤的 CATransform3D 动画不起作用

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

我有一个正在尝试制作的后续动画。它有两个步骤。

第 1 步:我选取图层并稍微改变视角,使其看起来像是图层的顶部向后移动。 sourceViewController.view.layer.transform CATransform3DMakePerspective(0, 0.003, CATransform3DIdentity);

第 2 步:我将比例更改为 80%,并将视角恢复正常。这给了它一个轻微的摆动缩小动画。

sourceViewController.view.layer.transform = CATransform3DScale(sourceViewController.view.layer.transform, 0.8, 0.8, 1);

sourceViewController.view.layer.transform CATransform3DMakePerspective(0, 0, sourceViewController.view.layer.transform);

我最大的问题是这个。我不能同时在图层上做 2 个动画。它会在第一次转换结束时自动开始,而不是同时进行。这可以通过 concat 解决,但由于我希望第 1 步在顶部发生,然后该层保存它的状态以便第 2 步可以发生,我无法将所有三个都连接起来。

如何着手创建在同一层上具有 1 个或多个变换的多步动画?就像我在下面的示例中所说的那样,它将跳过第 1 步并开始,就好像该步骤已经完成一样。我知道半混淆解释。这是我的动画。

[UIView animateWithDuration:2.0                        delay:0.0                        options:UIViewAnimationCurveEaseIn                      animations:^{                         sourceViewController.view.layer.transform = CATransform3DMakePerspective(0, 0.003, sourceViewController.view.layer.transform);                         [UIView animateWithDuration:1.0                                               delay:1.0                                             options:UIViewAnimationCurveEaseOut                                           animations:^{                                              sourceViewController.view.layer.transform = CATransform3DConcat(CATransform3DScale(sourceViewController.view.layer.transform, 0.8, 0.8, 1),CATransform3DMakePerspective(0, 0, sourceViewController.view.layer.transform));                                          }                                           completion:nil];                     }                      completion:^(BOOL finished){                     }];

我用谷歌搜索并尝试了一切。必须有一种方法可以在同一层上从最后一个 Sprite 离开的地方开始制作连续的动画。我传递的是图层而不是 CATransform3DIdentity,因为我读到身份恢复到起始状态,而不是图层转换到的位置。

最佳答案

您不想在第一个动画完成之前开始第二个动画。这就是完成 block 的用途。

[UIView animateWithDuration:2 delay:0 options:UIViewAnimationCurveEaseIn animations:^{
sourceViewController.view.layer.transform = CATransform3DMakePerspective(
0, 0.003, sourceViewController.view.layer.transform);
} completion:^(BOOL finished) {
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationCurveEaseOut animations:^{
sourceViewController.view.layer.transform = CATransform3DConcat(
CATransform3DScale(sourceViewController.view.layer.transform, 0.8, 0.8, 1),
CATransform3DMakePerspective(0, 0, sourceViewController.view.layer.transform));
} completion:nil];
}];

关于objective-c - 具有 2 个步骤的 CATransform3D 动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12762471/

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