美文网首页
iOS之【WEB隐藏元素】

iOS之【WEB隐藏元素】

作者: NJ_墨 | 来源:发表于2020-05-24 23:16 被阅读0次

隐藏网页元素

_web = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0,     self.view.frame.size.width, self.view.frame.size.height)];
_web.backgroundColor = [UIColor grayColor];
_web.scrollView.bounces = NO;
_web.scrollView.showsHorizontalScrollIndicator = NO;
_web.scrollView.scrollEnabled = NO;
_web.UIDelegate = self;
_web.navigationDelegate = self;
[self.view addSubview:_web];

NSURLRequest *rul = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://v.qq.com/x/page/h05060syc3z.html"]];
[_web loadRequest:rul];

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {

// 隐藏
[webView evaluateJavaScript:@"document.getElementsByClassName('cover-shadow')[0].style.display='none'" completionHandler:^(id _Nullable json, NSError * _Nullable error) {
    NSLog(@"json is %@, error is %@",json, error);

}];

[webView evaluateJavaScript:@"document.getElementsByClassName('cover-menu')[0].style.display='none'" completionHandler:^(id _Nullable json, NSError * _Nullable error) {
    NSLog(@"json is %@, error is %@",json, error);
    
}];

}

相关文章

网友评论

      本文标题:iOS之【WEB隐藏元素】

      本文链接:https://www.haomeiwen.com/subject/ukeydctx.html