我如何在iPhone应用程序中使用动画.gif? [英] How do I use an animated .gif in my iPhone application?

查看:159
本文介绍了我如何在iPhone应用程序中使用动画.gif?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动画gif文件,我想在我的iPhone应用程序中使用,但动画不起作用。是否有人知道如何解决它? 解决方案

如果您有一系列想要制作动画的图像, 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];

我发现这比使用UIWebView容易。


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?

解决方案

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.

这篇关于我如何在iPhone应用程序中使用动画.gif?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆