title: WKWebView embed YouTube scale video thumbnail
body: <p>I try to avoid this horrible output. I would like to present the initial YouTube video thumbnail filling the complete web view frame (WKWebView).</p>
  
  <p>It is the white rectangle in the picture.</p>
  
  <p><a href="https://i.stack.imgur.com/Uqb24.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uqb24.jpg" alt="iPhone screenshot"></a></p>
  
  <p>My code:</p>
  
  <pre><code>import WebKit
  
  class YouTube: UIViewController, WKUIDelegate {
  
  @IBOutlet weak var webView: WKWebView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      let videoID = "_g8aLVGXyc0"
      let youtubeURL = "https://www.youtube.com/embed/\(videoID)"
  
      webView.loadHTMLString("&lt;iframe width=\"560\" height=\"315\" src=\"\(youtubeURL)?&amp;rel=0\" frameborder=\"0\" allowfullscreen&gt;&lt;/iframe&gt;", baseURL: nil)
  </code></pre>
  
  <p>I try a lot of variety answers available on this site and Google in general.</p>
  
  <p>Same output if you try:</p>
  
  <p>width=\"(webView.frame.width)\" </p>
  
  <p>height=\"(webView.frame.height)\"</p>
  
  <p>Same output if you try:</p>
  
  <pre><code>webView.contentMode = UIViewContentMode.scaleToFill
  </code></pre>
  
  <p>Always the same.</p>