gpt4 book ai didi

ios - 如何设置具有延迟的显式 CA 动画的最终值

转载 作者:行者123 更新时间:2023-11-28 22:03:13 25 4
gpt4 key购买 nike

我有一个明确的动画,我想在其中设置最终值,以便对象停留在终点。但是我如何在延迟动画上实现这一点:这是代码:

CAKeyframeAnimation *moveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
moveAnimation.duration = 0.3;
moveAnimation.cumulative = YES;
moveAnimation.repeatCount = 1;

// Bounce
[moveAnimation setValues:[NSArray arrayWithObjects:
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:0 withIndex:i]],
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:radius + 10 withIndex:i]],
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:radius - 5 withIndex:i]],
[NSValue valueWithCGPoint:[self getCoordinatePointForAnimationWithRadius:radius withIndex:i]], nil]];

[moveAnimation setKeyTimes:[NSArray arrayWithObjects:
[NSNumber numberWithFloat:0],
[NSNumber numberWithFloat:0.5],
[NSNumber numberWithFloat:0.75],
[NSNumber numberWithFloat:1.0], nil]];

[moveAnimation setTimingFunctions:[NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil]];



moveAnimation.beginTime = CACurrentMediaTime() + 1 + (0.1 * i);


[layer addAnimation:opacityAnimation forKey:@"opacityAnimationUp"];
[layer addAnimation:moveAnimation forKey:@"moveAnimationUp"];

// That's not working correctly because of the delay
[layer setOpacity:1.0];
[layer setPosition:[self getCoordinatePointForAnimationWithRadius:radius withIndex:i]];

谢谢!

来自德国的问候,克里斯

最佳答案

看起来唯一缺少的是向后填充模式。这将导致动画在添加后立即显示第一个值,即使实际动画被延迟也是如此:

moveAnimation.fillMode = kCAFillModeBackwards;

关于ios - 如何设置具有延迟的显式 CA 动画的最终值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24596763/

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