ios - 动画图像到 UIImageView

标签 ios objective-c ipad uiimageview uiviewanimation

我必须将动画 Image 设置为 UIImageView。 请参阅下面的 Image 示例,我想在我的 UIImageView 上设置它,它具有扩展名 .GIF 并且我转换了将其转换为 .PNG 格式。

enter image description here

我已经尝试了太多方法来做到这一点。但没有得到预期的一个。我需要这种技术来创建我自己的自定义 Progressbar。 我将此图像分配给我的 UIImageView。但这不是动画.. 如果有人有任何想法,请与我分享。

最佳答案

您不能在 iOS 设备中使用 .gif 图片。不支持 GIF 动画。

相反,您可以将 .gif 的每一帧添加为 .png.jpg 图像,您可以通过代码。

NSArray *animateImagesArray = [NSArray arrayWithObjects:myUIImageOne, myUIImageTwo, myUIImageThree, nil];
yourImageView.animationImages      = animateImagesArray;
yourImageView.animationDuration    = 1.0f;
yourImageView.animationRepeatCount = 0; // Repeat forever
[yourImageView startAnimating];

另一种选择是,您可以放置​​一个 UIWebView 并在其中加载您的 gif

关于ios - 动画图像到 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27687355/

相关文章:

ios - 从 App Store 下载应用程序时崩溃,但在测试时不会崩溃

objective-c - 在 UIAutomation 测试期间禁用 iPad 上的网络

objective-c - 带有用于 Objective-C 的 ClientLogin 接口(interface)的 Google App Engine

iphone - iOS 6 自动旋转的问题

来自uitableview的iPad弹出窗口,是否使用披露指示器?

ios - 在 MKMapView 上绘制网格

ios - 单击按钮时隐藏键盘?

ios - 测试模拟关闭网络 iPad 测试仪 iOS

ios - NSFetchedResultsController 一次加载所有消息,获取批量大小没有修复它

iphone - IOS Dev Library 在你的 mac 上离线