Disclaimer: This article is a blogger original article, reproduced, please indicate the source of the article. https://blog.csdn.net/SunFlowerInRain/article/details/78677182
Project development process, after the completion of the process of loading a pdf file, often black screen appears;
because webview call -webViewDidFinishLoad:
after responsible for rendering UIWebPDFView pdf file has not finished loading, all want to get rid of the black background may be in -(void)viewDidLayoutSubviews
or
- (void)webView:(WKWebView *)webView
didFinishNavigation:(WKNavigation *)navigation
Re-set the background color is white UIWebPDFView
- (void)webView:(WKWebView *)webView
didFinishNavigation:(WKNavigation *)navigation
{
UIView *v = webView;
while (v) {
v.backgroundColor = [UIColor whiteColor];
v = [v.subviews firstObject];
}
}
Reference Links: https://stackoverflow.com/questions/45626151/ios-wkwebview-load-local-pdf-files-some-pages-become-black