2012-09-11 29 views
0

我有一个CABasicAnimation.fromValue.toValue,在一个PNG图像与图像202移动,并通过一个CABasicAnimation与帧

也我用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) , 

等....

任何想法??

回答

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]; 

希望这会有所帮助。

+0

我只有1图像包含202图像 – Mutawe

+0

考虑提取帧并保存为单独的图像。 –

+0

我没有工具给我通常相同的框架! – Mutawe