How to display GIF image on iPhone UIIMageView

I found several ways, but they actually read frames and apply a transition that reduces the quality of the animation. is there any way to display GIF in iPHone app as it is.? Thanks at Advance ..

+2
source share
2 answers

The animated GIF will not animate, but if you have a GIF, save each animation as a separate GIF, and then set up an arrayImages array with all these GIF files that 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]; 
+12
source

use 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 make your image and animate it as expected.

0
source

All Articles