Search code examples
iospdfwkwebviewios13

iOS WKWebView loading PDF data in DarkMode has black background around PDF document


After update to iOS 13 I have experienced problem with loading PDF document into WKWebView.

PDF document was displayed on light gray background in Light Mode. But now in iOS 13 I can change system configuration to Dark Mode. The problem is that PDF loaded in WKWebView gets black background around it instead of this light gray.

Now I don't want to implement Dark Theme for my app and stick with Light Theme all the time in Light Mode and Dark Mode. But this black background doesn't look good.

I also have no idea hot to change this, as this seems to be internal WKWebView implementation

[Light Mode [Dark Mode


Solution

  • Try to use UIUserInterfaceStyle flag with Light value in app's .plist file to avoid automatically changing colors in a whole app. If you want to do it for certain UIViewController or UIView - just override overrideUserInterfaceStyle property with UIUserInterfaceStyleLight or UIUserInterfaceStyleDark value.