我有一个 UIImageView,我正在尝试制作一组 UIImages 的动画,这些 UIImages 是通过翻转其他 UIImages 创建的。这是我的代码:
turtle = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width-200,
self.view.frame.size.height - sand.frame.size.height - turtle.frame.size.height - 10 - heightOfKeyboard,
100,100)];
[flippedTurtleArray addObject:[UIImage imageWithCGImage:[UIImage imageNamed:@"Turtle1.png"].CGImage scale:1 orientation:UIImageOrientationDownMirrored]];
[flippedTurtleArray addObject:[UIImage imageWithCGImage:[UIImage imageNamed:@"Turtle2.png"].CGImage scale:1 orientation:UIImageOrientationDownMirrored]];
[flippedTurtleArray addObject:[UIImage imageWithCGImage:[UIImage imageNamed:@"Turtle3.png"].CGImage scale:1 orientation:UIImageOrientationDownMirrored]];
[flippedTurtleArray addObject:[UIImage imageWithCGImage:[UIImage imageNamed:@"Turtle2.png"].CGImage scale:1 orientation:UIImageOrientationDownMirrored]];
[self.view addSubview: turtle];
问题是,当我尝试从翻转图像数组中对其进行动画处理时,它会显示原始图像,而不是翻转图像(即,当我这样做时):
turtle.animationImages = flippedTurtleArray;
turtle.animationDuration = 0.8f;
turtle.animationRepeatCount = 0;
[turtle startAnimating];
显示原始的非翻转图像。
现在,如果我这样做:
turtle.image = [flippedTurtleArray objectAtIndex:1];
显示翻转的图像。我想也许你不能用 CGImage 做动画,但找不到其他人有同样的问题。有任何想法吗?
谢谢,
山姆