UIImageView *_dogImageView = [[UIImageView alloc] init];
_dogImageView.frame = CGRectMake(0, 100, 300, 200);
[self.view addSubview:_dogImageView];
NSMutableArray* imageArray = [[NSMutableArray alloc] init];
for (int i = 1; i <= 20; ++i)
{
NSString* iname = [NSString stringWithFormat:@"dog_%d", i];
UIImage* image = [UIImage imageNamed:iname];
[imageArray addObject:image];
}
_dogImageView.animationImages = imageArray; //动画图片数组
_dogImageView.animationDuration = 2.5; //执行一次完整动画所需的时长
_dogImageView.animationRepeatCount = 0; // 执行一次, 然后自动消失
[_dogImageView startAnimating];