I want to load GIF in my swift 3 application. I used this code to do that but the gif is not showed.
let filePath = Bundle.main.path(forResource: “myGif”, ofType: "gif")
let gif = NSData(contentsOfFile: filePath!)
self.webView.load(gif! as Data, mimeType: "image/gif", textEncodingName: String(), baseURL: NSURL() as URL)
self.webView.isUserInteractionEnabled = false
I don't know what is wrong with my code (I'm really new to swift and iOS development).
Any help please?
I found SwiftGif Lbrary from github, it doesn't use webview (if you want to use webview write me to comments to update the answer)
EDIT:
Webview:
let url = Bundle.main.url(forResource: "source", withExtension: "gif")!
let data = try! Data(contentsOf: url)
webview.load(data, mimeType: "image/gif", textEncodingName: "UTF-8", baseURL: NSURL() as URL)
webview.scalesPageToFit = true
webview.contentMode = UIViewContentMode.scaleAspectFit
Hope it helps.