gpt4 book ai didi

iOS - 转到主屏幕并返回应用程序时脉冲动画暂停

转载 作者:行者123 更新时间:2023-11-28 20:10:37 25 4
gpt4 key购买 nike

我使用 CABasicAnimation 创建了一个脉冲动画,它运行良好,但我的问题是当我转到主屏幕或转到另一个 Storyboard并返回到应用程序或包含脉冲动画的 Storyboard时,脉冲动画暂停,所以这是我用来制作脉冲动画的代码

代码:

pbt.layer.transform = CATransform3DMakeScale(1.2, 1.2, 1);
CABasicAnimation *pulsy = [CABasicAnimation animationWithKeyPath:@"transform"];
pulsy.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
pulsy.autoreverses = YES;
pulsy.duration = 0.45;
pulsy.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pulsy.repeatCount = HUGE_VAL;
[pbt.layer addAnimation:pulsy forKey:@"pulseAnimation"];

最佳答案

添加这行代码:

pulsy.removedOnCompletion = NO;

所以你的代码将是:

pbt.layer.transform = CATransform3DMakeScale(1.2, 1.2, 1);
CABasicAnimation *pulsy = [CABasicAnimation animationWithKeyPath:@"transform"];
pulsy.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
pulsy.autoreverses = YES;
pulsy.duration = 0.45;
pulsy.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pulsy.repeatCount = HUGE_VAL;
pulsy.removedOnCompletion = NO;
[pbt.layer addAnimation:pulsy forKey:@"pulseAnimation"];

关于iOS - 转到主屏幕并返回应用程序时脉冲动画暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20439730/

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