动画图像到 UIImageView

Sar*_*tel 3 objective-c uiimageview ipad uiviewanimation ios

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

在此处输入图片说明

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

Mid*_* MP 5

您不能.gif在 iOS 设备中使用图像。不支持 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];
Run Code Online (Sandbox Code Playgroud)

另一种选择是,您可以将 a 放入其中UIWebView并加载gif