Objective c 动画不设置图像序列的动画
我在用动画制作动画方面遇到了麻烦,它似乎没有给我任何错误,但它不是动画。我很困惑Objective c 动画不设置图像序列的动画,objective-c,caanimation,Objective C,Caanimation,我在用动画制作动画方面遇到了麻烦,它似乎没有给我任何错误,但它不是动画。我很困惑 NSMutableArray *animationImages = [NSMutableArray array]; //Adding images into array for (int i=0;i<=5;i++){ UIImage *imgfile = [NSString stringWithFormat:@"%@/ConusOverlay/%d_ConusOverlay.gif",document
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"];
NSMutableArray*animationImages=[NSMutableArray];
//向数组中添加图像
对于(int i=0;iCoreAnimation通常使用cImageRef
s而不是UIImages
。请尝试按照您的建议将图像
替换为(id)图像。cImage
。数组可以存储cImageRef
s!非常感谢您的帮助,我将[animationSequenceArray addObject:image]更改为[animationSequenceArray addObject:(id)image.CGImage.效果很好,再次感谢。