i want hide/show navigationbar of uinavigationcontroller
when wkwebview
zooms out/in.
to hide or show uinavigationbar
quite easy follows:
self.navigationcontroller?.navigationbarhidden = true
but problem don't know put code.
i thinking intercept zoom event of wkwebview
. may there other ways, comments welcome.
every wkwebview
has scrollview
property allows access uiscrollview
part of the web view. can use uiscrollviewdelegate
method, scrollviewdidscroll
callbacks on when web view scrolls.
first, set scroll view delegate:
let webview = wkwebview(...) webview.scrollview.delegate = self
then, implement delegate method scrollviewdidscroll
, add logic hide , show navigation bar:
extension yourclass: uiscrollviewdelegate { func scrollviewdidscroll(scrollview: uiscrollview) { // can use position of scrollview show , hide nav bar here } }
Comments
Post a Comment