4

在我的 iOS 应用程序中使用 Google WebP 图像格式时,我发现 Google 的库擅长在本机代码中显示 WebP 图像。

现在我也想在我的 webapp 中使用 WebP,但 UIWebView 不支持。有什么想法可以实施吗?

4

4 回答 4

0

如果您使用的是 Cordova/Phonegap,有一个插件可以将 WebP 支持添加到 UIWebView。如果您不使用 Cordova,您应该能够使用相同的机制而无需插件注册。

https://github.com/dpogue/cordova-plugin-webp

于 2014-11-25T05:54:38.427 回答
0

您可以使用 Pod https://github.com/rs/SDWebImage

POD:-pod 'SDWebImage/WebP'

使用 Swift 4.2:

let thumbimgurl = URL(string: "https://res.cloudinary.com/demo/image/upload/w_300/sample.webp")

SDWebImageManager.shared().loadImage(with: thumbimgurl, options: .highPriority, progress: nil) { (DisplayUIImage, ImageSize, Error, SDImageCacheType, ImageBool, ImageURL) in

self.MyImageDisplayImageView.image = DisplayUIImage

}
于 2018-10-16T06:58:25.380 回答
0

您可以使用 Pod https://github.com/rs/SDWebImage

从 Web 加载 WebP 图像真的很容易

使用斯威夫特:

SDWebImageManager.shared().loadImage(with: url, options: .highPriority, progress: nil, completed: {(resultSet) in
            YOURWEBVIEW.image = resultSet.0

        })
于 2017-06-12T12:44:34.343 回答
0

如果您的资源在您的包中,您可以使用SDWebImage库以这种方式执行此操作:

let webpData: Data = try Data(contentsOf: Bundle.main.url(forResource: "your_resource_name", withExtension:"webp")!)
imageView.image = SDImageWebPCoder.shared.decodedImage(with: webpData, options: nil)
于 2019-12-03T10:30:34.957 回答