Is it possible to remove [“Page 1 of 20” view] in a UIwebview when displaying pdf?

前端 未结 4 1383
我在风中等你
我在风中等你 2021-01-12 20:02

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

4条回答
  •  广开言路
    2021-01-12 20:53

    This code is working on iOS9, 10 (tested)

        func hidePageNumberView(v: UIView) {
            for subView in v.subviews {
                if subView.isKindOfClass(UIImageView) || subView.isKindOfClass(UILabel) || subView.isKindOfClass(UIVisualEffectView){
                    subView.hidden = true
    
                    if subView.isKindOfClass(UILabel) {
                        if let sv = subView.superview {
                            sv.hidden = true
                        }
                    }
                } else {
                    hidePageNumberView(subView)
                }
            }
        }
    

    Implement webView.scrollView.delegate and run above code in scrollViewDidScroll

    Hope this help.

    iOS 11 / Swift 4:

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        hidePageNumberView(scrollView)
    }
    
    func hidePageNumberView(_ v: UIView) {
        for subView in v.subviews {
            if subView is UIImageView || subView is UILabel || subView is UIVisualEffectView {
                subView.isHidden = true
    
                if subView is UILabel {
                    if let sv = subView.superview {
                        sv.isHidden = true
                    }
                }
            } else {
                hidePageNumberView(subView)
            }
        }
    }
    

提交回复
热议问题