将准备好的图片放到一个数组里面,代码如下:
NSArray *images = [NSArray arrayWithObjects: [UIImage imageNamed:@"1.jpg"],
[UIImage imageNamed:@"2.jpg"],
nil];
下面代码完成,显示就可以了
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
imageView.animationImages = myImages;
imageView.animationDuration = 1.5; //浏览整个图片一次所用的时间
imageView.animationRepeatCount = 0; // 动画重复次数,0表示一直重复着
[imageViewstartAnimating];
[self addSubview:imageView];
[imageViewrelease];