wkWebView 或者 webView 在客户端隐藏某些布局的方法

首先 我们需要拿到我们需要操作的H5的布局代码(可以根据className 或者其他的 唯一ID标识)

比如 

这段代码中 我们可以根据  <footer class="published text-center"> 中的 published text-center 这个 使用 document.getElementsByClassName('published text-center') 拿到这一部分的UI设置

然后 使用

NSString * logoStr = @"document.getElementsByClassName('published text-center')[0].style.display='none'"  来设置UI隐藏 

最后 我们 调用 

- (void)evaluateJavaScript:(NSString *)javaScriptString completionHandler:(void (^ _Nullable)(_Nullable id, NSError * _Nullable error))completionHandler;

这个方法 将logoStr 传入进去 就可以实现了

另外 我们可以在block 中做一些 其他的 我们想做的操作

 

原文地址:https://www.cnblogs.com/LoveStoryJX/p/9372895.html