//webview 自适应高度
CGFloat height = [[_webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue] + 20;
_webView.frame = CGRectMake(0, _heightSize, SCREEN_WIDTH, height);
//加入css样式和html的设置
- (NSString *)reSizeImageWithHTML
{
NSString *cssLine = @"<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" integrity=\"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u\" crossorigin=\"anonymous\"";
NSString *htmlUrl = [NSString stringWithFormat:@"%@%@",cssLine,_content];
// NSString *htmlUrl = [NSString stringWithFormat:@"<head><style>img{width:100%%;}body{color: #5b5c7e;font-size: 14px;}</style></head>%@%@",cssLine,_content];
return htmlUrl;
}
来源:CSDN
作者:qq_31292239
链接:https://blog.csdn.net/qq_31292239/article/details/75222186