'iOS WKWebview load local PDF Files some pages become black

I user wkwebview to load a local pdf file and it works fine. But when I scroll up and down to some pages, some pages become black. Have you also come across this problem?

enter image description here



Solution 1:[1]

This one works for me.

Assuming you are implementing WKNavigationDelegate (YourWebView.navigationDelegate) in your ViewController.

- (void)webView:(WKWebView *)webView 
didFinishNavigation:(WKNavigation *)navigation 
{
   UIView *v = webView;
    while (v) {
        v.backgroundColor = [UIColor whiteColor];
        v = [v.subviews firstObject];
    }
}

For reference: Rendering PDF in UIWebView iOS 8, causes a black border around PDF

Solution 2:[2]

For iOS 11.0+ use PDFView (also see PDFKit) to display a PDF. PDFView does not have the issue with black pages.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fertos
Solution 2 christopher.online