隐藏网页元素
_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);
}];
}
网友评论