多张图片整合成连续动画的代码

来源:互联网 发布:java ide 编辑:程序博客网 时间:2024/05/16 09:03

循环播放的代码

UIImageView* animView= [[UIImageView alloc] initWithFrame:self.view.frame];
     animView.animationImages = [NSArray arrayWithObjects:    
                                 [UIImage imageNamed:@"01.gif"],
                                 [UIImage imageNamed:@"02.gif"],
                                 [UIImage imageNamed:@"03.gif"],nil];
     
     // all frames will execute in 1.75 seconds
     animView.animationDuration = 1.75;
     // repeat the annimation forever
     animView.animationRepeatCount = 0;
     // start animating
     [animView startAnimating];
     // add the animation view to the main window 
     [self.view addSubview:animView];