将gif从缓存加载到loadHTMLString Swift中

时间:2019-06-16 17:00:37

标签: swift

所以我想将gif从本地文件url加载到我的UIWebview

使用sdwebimage缓存gif即时消息,而我正在获取gif的本地网址

localGifUrl = "file:///var/mobile/Containers/Data/Application/8JA6F4A5-879A-4251-8F83-D42C18B54HBK/Library/Caches/default/com.hackemist.SDWebImageCache.default/6e8d0fcfbedf08ed527fd5dc9fb178a8.gif"

然后我正在使用loadHTMLString将gif放入图像

let fullHTML = "<!DOCTYPE html>" +
                    "<html lang=\"ja\">" +
                    "<head>" +
                    "<meta charset=\"UTF-8\">" +
                    "<style type=\"text/css\">" +
                    "html{margin:0;padding:0;}" +
                    "body {" +
                    "margin: 0;" +
                    "padding: 0;" +
                    "color: #fff;" +
                    "font-size: 90%;" +
                    "line-height: 1.6;" +
                    "background: white;" +
                    "}" +
                    "img{" +
                    "position: absolute;" +
                    "top: 0;" +
                    "bottom: 0;" +
                    "left: 0;" +
                    "right: 0;" +
                    "margin: auto;" +
                    "max-width: 100%;" +
                    "max-height: 100%;" +
                    "}" +
                    "</style>" +
                    "</head>" +
                    "<body id=\"page\">" +
                "<img src='\(localGifUrl)'/> </body></html>"
                self.pdfWebView.loadHTMLString(fullHTML, baseURL: nil)

这似乎不起作用,我缺少什么吗?

第二种方法..我试图将图像转换为base64,但是gif被转换为图像文件。

0 个答案:

没有答案