2012-02-07 57 views
0

我在使用CAAnimation进行动画制作时遇到了麻烦,它似乎没有给出任何错误,但它不具有动画效果。我很困惑CAAnimation不会动画我的图像序列

NSMutableArray *animationImages = [NSMutableArray array]; 
//Adding images into array 
for (int i=0;i<=5;i++){ 
    UIImage *imgfile = [NSString stringWithFormat:@"%@/ConusOverlay/%d_ConusOverlay.gif",documentsPath,i]; 
    [animationImages addObject: imgfile]; 
} 

CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"]; 
animationSequence.calculationMode = kCAAnimationLinear; 
animationSequence.autoreverses = NO; 
animationSequence.duration = 1; 
animationSequence.repeatCount = HUGE_VALF; 

NSMutableArray *animationSequenceArray = [NSMutableArray array]; 
for (UIImage *image in animationImages) { 
    [animationSequenceArray addObject:image]; //<--Does this have to be (id)image.CGImage ?, if I am correct you are unable to add CGImage to an array 
} 
animationSequence.values = animationSequenceArray; 
[mlLayer.contents addAnimation:animationSequence forKey:@"contents"]; 

回答

1

CoreAnimation通常需要CGImageRef秒且不UIImages。按照您的建议,尝试使用(id)image.CGImage替换image。阵列可以存储CGImageRef s!

+0

非常感谢你的工作,我将[animationSequenceArray addObject:image]更改为[animationSequenceArray addObject:(id)image.CGImage。精美的作品,再次感谢。 – 2012-02-07 19:02:35