Transparent background for WKWebView

In my app I wish to make the WKWebView with transparent background, so the view behind (an ImageView) can show through as background picture.

    webView!.opaque = false
    webView!.backgroundColor = UIColor.clearColor()

The code above works fine with UIWebView, but if webView is WKWebView, a white background will be shown.

Also tried putting transparent background color in CSS. The result is the same, only works in UIWebView but not WKWebView. Any suggestion?


For iOS 10+ using Swift:

self.webView = WKWebView()
self.webView!.isOpaque = false
self.webView!.backgroundColor = UIColor.clear
self.webView!.scrollView.backgroundColor = UIColor.clear

This code might help you. Updated for Swift 3+

self.webView = WKWebView()
self.webView.isOpaque = false
self.webView.backgroundColor = UIColor.clear
self.webView.scrollView.backgroundColor = UIColor.clear