Для использования файла with.gif расширения вы можете использовать эту третью часть-библиотеки FLAnimatedImage. Это хорошая библиотека с демонстрационным приложением.
Вы также можете изменить код, чтобы сделать работу так, как вы хотите. Если у вас есть массив изображения (.png или другого внутреннего абонента), вы можете использовать APPLE UIImageView:
NSMutableArray* animation = [[NSMutableArray alloc] init];
for(int i = 0; i<20; i++)
{
[animation addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image_%i",i]]];
}
UIImageView *player = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
[player setAnimationImages:animation];
[player setAnimationRepeatCount:0]; //0 means infinite loop
player.animationDuration = 2.f;// time for one hole loop for animation
[self.view addSubview:player];
[player startAnimating];//start animation
[player stopAnimating];//stop animation
Также вы можете использовать CAKeyframeAnimation. Он может сообщить вам, когда начинается и заканчивается анимация.
UIImageView *animatedImageView = [[UIImageView alloc] init];
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
animation.calculationMode = kCAAnimationDiscrete;
animation.duration = 3.0f;
animation.values = someArrayWithImages;
animation.repeatCount = 1;
animation.delegate = self;
[animatedImageView.layer addAnimation:animation forKey:@"animation"];
И добавить делегат методы:
- (void)animationDidStart:(CAAnimation *)anim;
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag;
одна точка, это изображение уже тип анимации ... –