How to change webview background color and text color in Swift

Viewed 19

I am loading dynamic html string which is coming from server response. But, In my app, We are handling light and dark mode. I am able to change webview's background color, but I am unable to change the text color. It is showing always black text color irrespective of mode.

I want to show black text color for light mode and white text color for dark mode.

Any suggestions?

 func displayData() {
        
        if let contentData = self.response?.data?.content {
            do {
                self.webView.loadHTMLString(contentData, baseURL: nil)
            } catch {
                print(error)
            }
        }
    }
0 Answers
Related