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

后端 未结 5 1307
有刺的猬
有刺的猬 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:11

    If you have a serie of images you want to animate you can easily do it with UIImageView:

    UIImage *blur5 = [UIImage imageNamed:@"blur5.png"];
    UIImage *blur6 = [UIImage imageNamed:@"blur6.png"];
    
    self.imageView.animationImages = [[NSArray alloc] initWithObjects:blur5, blur6, nil];
    self.imageView.animationRepeatCount = 5;
    [self.imageView startAnimating];
    

    I found this easier than trying to use UIWebView.

提交回复
热议问题