gpt4 book ai didi

iphone - 如何让 CAKeyframeAnimation 在覆盖另一个 CAKeyframeAnimation 时获取当前状态?

转载 作者:行者123 更新时间:2023-12-03 19:43:09 25 4
gpt4 key购买 nike

我有一个这样的:

CALayer *layer = stripeButton.layer;
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"bounds.origin.y"];
moveAnim.duration = 3.35;
moveAnim.repeatCount = 0;
moveAnim.autoreverses = NO;
moveAnim.removedOnCompletion = NO;
moveAnim.calculationMode = kCAAnimationLinear;
moveAnim.fillMode = kCAFillModeForwards;

// ... keys and values here ...

[theLayer addAnimation:moveAnim forKey:@"theAnimation"];

您会看到该动画持续 3.35 秒。同时,可能会在 2 秒时启动具有相同键 @“theAnimation”的新动画,但值不同。

发生的问题:新动画未采用当前可见状态。从头开始,一切都很艰难。 View 以一种丑陋的方式跳转到开始位置,从那里开始新的动画。对于 UIView 有一个 setAnimationsBeginFromCurrentState=YES,但我还没有找到类似 CAKeyFrameAnimation 的东西。有什么想法吗?

最佳答案

您想要查询图层的表示层,这是其当前的插值状态,包括当前正在运行的任何动画。

-

摘自 CALayer 类引用:

 -(id)presentationLayer

返回包含当前事务开始时所有属性的图层副本,并应用了任何事件动画。

-

CA 编程指南中解释了图层树(您的数据)、表示树(数据的当前插值)和渲染树之间的关系。

Core Animation Rendering Architecture

关于iphone - 如何让 CAKeyframeAnimation 在覆盖另一个 CAKeyframeAnimation 时获取当前状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1318387/

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