简体   繁体   English

如何在iPhone UIIMageView上显示GIF图像

[英]How to Display GIF Image on iPhone UIIMageView

i have found some ways but they are actually reading frames and applying transition which reduces the quality of animation.. is there any way to display GIF on iPHone application as it is..? 我找到了一些方法,但他们实际上是阅读框架和应用转换,这降低了动画的质量..有没有办法在iPHone应用程序上显示GIF,因为它是..? Thanks in Advance.. 提前致谢..

Animated GIF won't animate, but if you have a GIF, save each animation as a separate GIF and then setup animationImages array with all those GIFs you just saved: 动画GIF不会设置动画,但如果您有GIF,请将每个动画保存为单独的GIF,然后使用您刚刚保存的所有GIF设置animationImages数组:

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                               [UIImage imageNamed:@"image1.gif"],
                               [UIImage imageNamed:@"image2.gif"],
                               [UIImage imageNamed:@"image3.gif"],
                               [UIImage imageNamed:@"image4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

use a web view. 使用Web视图。

    if let path = Bundle.main.path(forResource: "animated", ofType: "gif") {
        let url = URL(fileURLWithPath: path)
        let request = URLRequest.init(url: url)
        webview.loadRequest(request)
    }

this will render your image and animate it as expected. 这将渲染您的图像并按预期动画。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM