2012-02-07 2 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

코어 애니메이션은 보통 CGImageRef의하지 UIImages 소요 혼란 스러워요. 제안한대로 image(id)image.CGImage으로 바꿔보십시오. 배열은 CGImageRef s를 저장할 수 있습니다!

+0

대단히 감사합니다. [animationSequenceArray addObject : image]를 [animationSequenceArray addObject : (id) image.CGImage]로 변경했습니다. 아름답게 작동합니다, 다시 한번 감사드립니다. –