How do I use an animated .gif in my iPhone application?

后端 未结 5 1306
有刺的猬
有刺的猬 2020-12-12 16:45

I have an animated gif file that I want to use in my iPhone application, but the animation doesn\'t work. Does anybody know how to fix it?

5条回答
  •  离开以前
    2020-12-12 17:12

    This can be achieved by this piece of code:

    NSArray * imageArray  = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], nil]; //this will be the frames of animation images in sequence.
     ringImage = [[UIImageView alloc]initWithFrame:CGRectMake(100,200,600,600)];
     ringImage.animationImages = imageArray;
     ringImage.animationDuration = 1.5;//this the animating speed which you can modify
     ringImage.contentMode = UIViewContentModeScaleAspectFill;
     [ringImage startAnimating];//this method actually does the work of animating your frames.
    

    I know its an old thread..but may be helpful for someone..:)

提交回复
热议问题