gpt4 book ai didi

ios - 以编程方式 easeOut UIImageView animationImages

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

除了在图像编辑软件中手动调整 PNG 之外,有没有办法以编程方式简化此动画?即:显示缓出效果。除非我使用错误的关键字来搜索答案,否则我已经看过但没有在网上看到答案。

NSMutableArray * images = [@[] mutableCopy];

for (int i = currentFrame; i <= maxFrame; i++) {

NSString * imageString = [NSString stringWithFormat:@"icon_introchart_%ld",i];
UIImage * newImage = [UIImage imageNamed:imageString];
[images addObject:newImage];

}

_introChart.animationImages = images;
_introChart.animationDuration = 2.0f;
_introChart.animationRepeatCount = 1;

已编辑 -> 但我仍然遗漏了一些东西:

CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
[animation setCalculationMode:kCAAnimationLinear];
animation.duration = 2.0;
animation.values = images;
animation.repeatCount = 1;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[animation setRemovedOnCompletion:YES];
[_introChart.layer addAnimation:animation forKey:@"contents"];

// _introChart.animationImages = images;
// _introChart.animationDuration = 2.0f;
//_introChart.animationRepeatCount = 1;

编辑:我需要为“内容”提供 CGImageRefs 而不是 UIImages...它现在可以工作了。

UIImage * newImage = [UIImage imageNamed:imageString];
CGImageRef cgImage = [newImage CGImage];
[images addObject:(__bridge id)(cgImage)];

最佳答案

简单的 UIImage 动画就是这么简单。你当然可以做你想做的事,但你必须使用真实的动画才能获得你所要求的那种时间控制。最简单的方法可能是使用 CAKeyframeAnimation,它可以让您控制动画“帧”的时间。

关于ios - 以编程方式 easeOut UIImageView animationImages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27805203/

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