gpt4 book ai didi

iphone - 如何删除动画(CABasicAnimation)?

转载 作者:行者123 更新时间:2023-12-03 16:12:15 29 4
gpt4 key购买 nike

我想在动画 (CABasicAnimation) 完成之前将其删除。

例如:

在我的代码中,我启动了针从旋转值 0 到目标值 5 的动画。当针达到旋转值 3 时如何停止动画?

CALayer* layer = someView.layer;
CABasicAnimation* animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0];
animation.toValue = [NSNumber numberWithFloat:5];
animation.duration = 1.0;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
[layer addAnimation:rotationAnimation forKey:@"transform.rotation.z"];

最佳答案

[layer removeAnimationForKey:@"transform.rotation.z"];

layer.removeAnimation(forKey: "bounce")

还有

layer.removeAllAnimations()

关于iphone - 如何删除动画(CABasicAnimation)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1435094/

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