How do you resize the gif displayed in WKWebView

I want to display a gif that it fits in WKWebView. (like Aspect fit.)

gif is stored locally.

This is sample code and Autolayout.↓

import UIKit
import WebKit

class ViewController: UIViewController {

  @IBOutlet weak var webView: WKWebView!
   
  override func viewDidLoad() {
    super.viewDidLoad()
     
    guard let url = Bundle.main.url(forResource: "sample", withExtension: "gif"),
       let data = try? Data(contentsOf: url),
       let baseURL = Foundation.URL(string: "about:blank") else {
      return
    }
    webView.load(data, mimeType: "image/gif", characterEncodingName: "UTF-8", baseURL: baseURL)
     
  }

}

use the gif from this link.↓

https://sozai-good.com/illust/animal/5677

When run this code, the gif is cut off. (use iPhone13 pro)

How do you resize the gif?

Answered by kentyam in 724591022

I was able to resize using HTML. Thank you.

Accepted Answer

I was able to resize using HTML. Thank you.

How do you resize the gif displayed in WKWebView
 
 
Q