2013-04-02 104 views
2

我有一组图像面向一侧(人面向右侧),我用它翻转它,然后将它添加到uiimageview的animationImages中。但是,在添加翻转的图像后,开始生成动画后,动画仍然面向右侧。UIImageView的开始动画没有动画翻转图像

manRunAnimations = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)]; 
NSArray *manAniRunArray = @[[UIImage imageNamed:@"robot1"], 
          [UIImage imageNamed:@"robot2"], 
          [UIImage imageNamed:@"robot3"], 
          [UIImage imageNamed:@"robot4"], 
          [UIImage imageNamed:@"robot5"], 
          [UIImage imageNamed:@"robot6"], 
          ]; 


manRunAnimationsf = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 64, 64)]; 

NSMutableArray *flippedRunAnimationImages = [[NSMutableArray alloc] init]; 

for(UIImage *image in manAniRunArray) 
{ 
    UIImage * flippedImage = [UIImage imageWithCGImage:image.CGImage scale:image.scale orientation:UIImageOrientationRightMirrored]; 
    [flippedRunAnimationImages addObject:flippedImage]; 
} 

manRunAnimationsf.animationImages = (NSArray *)flippedRunAnimationImages; 

testImgView.image = [manRunAnimationsf.animationImages objectAtIndex:0]; 
manRunAnimationsf.animationDuration = runAnimationSpeedSlider.value; 
[manRunAnimationsf startAnimating]; 

我使用

testImgView.image = [manRunAnimationsf.animationImages objectAtIndex:5]; 

这将显示翻转图像的一个正确屏幕上我做了

[manRunAnimationsf startAnimating]; 

之前一旦开始,动画甚至测试它根本不翻转!

任何人都知道为什么?

+0

你们认为与使用“imageNamed”方法的缓存图像有某种关系? – mskw

回答

2

我不能相信没有人知道为什么,但我找到了解决方法。是我startAnimating之前增加以下内容:

manRunAnimationsf.transform = CGAffineTransformMake(-1,0,0,1,0,0); 

我都不需要做CGImage在翻转的循环。

但手动图像翻转应该已经与imageWithCGImage方法,我真的想知道为什么!你们让我失望。 :p

+0

任何人都有洞察力的评论? – mskw

+0

我正在遭受同样的困境,至今还没有可能的答案 – tGilani

+0

检查我的答案男人! – mskw