2010-04-05 84 views
1

GIF图片我已经找到了一些办法,但它们实际上是阅读框和应用过渡从而降低动画的质量.. 有没有办法在iPhone上的应用程序显示GIF,因为它是...? 在此先感谢..如何显示在iPhone上的UIImageView

+0

必须使用GIF?你可以使用一系列PNG吗? – kennytm 2010-04-05 13:37:41

+0

你想显示一个GIF动画? – runmad 2010-04-05 13:37:49

回答

11

GIF动画将无法运行动画,但如果你有一个GIF,保存每个动画作为一个单独的GIF,然后设置animationImages阵列与所有那些你刚刚保存的GIF:

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]; 
0

使用网络视图。

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

这将呈现您的图像并按预期设置动画效果。