Wrap content WKWebview in Swift

Viewed 15

I am a beginner IOS developer. I have created an application to show overlay from the link HTTP but I can't wrap_content like Android.

When I receive a notification from the socket with link HTTP Overlay, I will create WKWebview and load that link HTTP Overlay and add it into the UIView. But like the image below, WKWebview does not crop to only show the content of the overlay.

I searched similar question on StackOverflow and tried but it didn't work

    let overlay: UIView
    let web = WKWebView.init(frame: CGRect(x: 0, y: 0, width: 600, height: 200)
    let url = URL.init(string: websiteAddress)!
    let request = URLRequest.init(url: url)
    web.load(request)
    web.backgroundColor = nil
    web.configuration.defaultWebpagePreferences.allowsContentJavaScript = true
    overlay.addSubview(web)

enter image description here

0 Answers
Related