我有CABasicAnimation
.fromValue
和.toValue
在PNG图像中移动202张图片并逐个显示
我还使用CALayer
来保存image.png
它按顺序传递所有图像的问题
我希望按照我将放在NSArray
这是我的代码:
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"];
anim.fromValue = [NSNumber numberWithInt:1];
anim.toValue = [NSNumber numberWithInt:203];
anim.duration = 1.75f;
anim.repeatCount = HUGE_VALF;
anim.autoreverses = YES;
[myImage addAnimation:anim forKey:nil];
并且帧数组是:
frames = (753, 377, 798, 422) ,
(706, 377, 751, 422) ,
(659, 377, 704, 422) ,
(612, 377, 657, 422) ,
(565, 377, 610, 422) ,
(518, 377, 563, 422) ,
(518, 424, 563, 468) ,
(471, 424, 516, 468) ,
(424, 424, 469, 468) ,
(471, 377, 516, 422) ,
(424, 377, 469, 422) ,
(377, 377, 422, 422) ,
(330, 377, 375, 422) ,
依旧......
任何想法?
答案 0 :(得分:1)
与您的帧阵列类似,您可以将所有需要的图像(帧)添加到UIImageView。这是一个例子:
NSArray *images = [NSArray arrayWithObjects:
[UIImage imageNamed:@"frame753.png"],
[UIImage imageNamed:@"frame377.png"],
[UIImage imageNamed:@"frame798.png"],
nil];
yourImageView.animationImages = images;
yourImageView.animationDuration = 1.75;
yourImageView.animationRepeatCount = 0;
[yourImageViewstartAnimating];
希望这有帮助。