【发布时间】:2016-10-24 05:44:41
【问题描述】:
我找到了一些方法,但它们实际上是在读取帧并应用降低动画质量的过渡。 有没有办法在 iPHone 应用程序上显示 GIF 原样..? 在此先感谢..
【问题讨论】:
-
必须使用 GIF 吗?你能用一个PNG序列来代替吗?
-
您想要显示动画 GIF?
标签: iphone uiimageview
我找到了一些方法,但它们实际上是在读取帧并应用降低动画质量的过渡。 有没有办法在 iPHone 应用程序上显示 GIF 原样..? 在此先感谢..
【问题讨论】:
标签: iphone uiimageview
动画 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];
【讨论】:
使用网络视图。
if let path = Bundle.main.path(forResource: "animated", ofType: "gif") {
let url = URL(fileURLWithPath: path)
let request = URLRequest.init(url: url)
webview.loadRequest(request)
}
这将呈现您的图像并按预期对其进行动画处理。
【讨论】: