开发者

How to Display GIF Image on iPhone UIIMageView

开发者 https://www.devze.com 2022-12-25 12:06 出处:网络
i have found some ways but they are actually reading frames and applying transition which reduces the quality of animation..

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 a开发者_如何学Cpplication as it is..? 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:

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.

    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.

0

精彩评论

暂无评论...
验证码 换一张
取 消