I can not get to a solution after much googling. I have a UIWebView with a PDF in it.
I do not want the view: \"Page 1 of 20\" The small view in the upper left corn
Swift 3 and WKWebView
I get all the subviews of the WKWebView
and then remove WKPDFPageNumberIndicator
:
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
let webViewSubviews = self.getSubviewsOfView(v: self.webView)
for v in webViewSubviews {
if v.description.range(of:"WKPDFPageNumberIndicator") != nil {
v.isHidden = true // hide page indicator in upper left
}
}
}
func getSubviewsOfView(v:UIView) -> [UIView] {
var viewArray = [UIView]()
for subview in v.subviews {
viewArray += getSubviewsOfView(v: subview)
viewArray.append(subview)
}
return viewArray
}
You'll probably have to set webView.navigationDelegate = self
UPDATE (not tested) - Swift 4
Keep the getSubviewsOfView
function from above and modify the webView function like this:
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
let webViewSubviews = self.getSubviewsOfView(v: self.webView)
for v in webViewSubviews {
if v.isKind(of: UILabel.self) || v.isKind(of: UIImageView.self) || v.isKind(of: UIVisualEffectView.self) {
v.isHidden = true
}
}
}