UIImageView可以反转动画吗?

时间:2010-07-05 03:05:17

标签: iphone animation uiimageview

我尝试在UIImageView上制作动画。够了吗?或者我需要使用Core动画?

我想动画

图片1,2,3,...,14

如何从14,13,12,...,1恢复活力

这是我的代码

NSArray *myImages = [NSArray arrayWithObjects: 
                     [UIImage imageNamed:@"phe01.png"],
                         [UIImage imageNamed:@"phe02.png"],
                         [UIImage imageNamed:@"phe03.png"],
                         [UIImage imageNamed:@"phe04.png"],
                         [UIImage imageNamed:@"phe05.png"],
                         [UIImage imageNamed:@"phe06.png"],
                         [UIImage imageNamed:@"phe07.png"],
                         [UIImage imageNamed:@"phe08.png"],
                         [UIImage imageNamed:@"phe09.png"],
                         [UIImage imageNamed:@"phe10.png"],
                         [UIImage imageNamed:@"phe11.png"],
                         [UIImage imageNamed:@"phe12.png"],
                         [UIImage imageNamed:@"phe13.png"],
                         [UIImage imageNamed:@"phe14.png"],
                         nil];

    UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 460-256,  320, 256)];
//  [myAnimatedView initWithFrame:[self bounds]];
    myAnimatedView.animationImages = myImages;
    //myAnimatedView.animationDuration = 0.75; // seconds
    myAnimatedView.animationRepeatCount = 0; // 0 = loops forever
    //myAnimatedView.autoreverses=YES;
    [myAnimatedView startAnimating];
    [self.view addSubview:myAnimatedView];
    [myAnimatedView release]; 

1 个答案:

答案 0 :(得分:0)

请参阅How do you "ping pong" a UIView image sequence animation,但请注意,许多人遇到与使用UIImageView.animationImages相关的崩溃和内存不足问题,最好重新考虑基本方法,以便一次只能在内存中保留1个图像。