我有一個UIImageView,我試圖做一個UIImages動畫的創建通過翻轉其他UIImages。這裏是我的代碼:UIImageView將不會動畫與UIImages的CGImage
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做動畫,但是找不到其他人有同樣的問題。有任何想法嗎?
感謝,
山姆
嗨 - 我將如何將翻轉的圖像渲染成單獨的圖像?我看不到如何做到這一點? –
阿好 - 知道了 - 我改變方法,只是發現如何翻轉實際圖像數據而不是國旗。不管怎麼說,還是要謝謝你。 –