Adding a header view to a UIWebView similar to Safari and Articles

前端 未结 7 1862
耶瑟儿~
耶瑟儿~ 2020-12-07 19:17

I\'d like to add a header view to an UIWebView similar to the address/search bar in MobileSafari and the excellent Articles.app by Sophia Teutschler. More preci

7条回答
  •  执笔经年
    2020-12-07 20:01

    I think the best solution is to add the header as a subview of your UIWebView’s scrollView, adjust UIEdgeInsets, and in the scrollViewDidScroll delegate function adjust the scrollIndicatorInsets as needed.

    Every other solution I found didn't account for the scroll indicators.

    Since getting the behavior just right has a bit of complexity to it, I decided to write a class to handle all of it: MMWebViewWithSmartHeader. It's still a little rough around the edges but should help.

提交回复
热议问题