self.content = [self.content stringByReplacingOccurrencesOfString:@"\\" withString:@""];
NSString *str = [NSString stringWithFormat:@"<!DOCTYPE html>\
<html lang='en'>\
<head>\
<meta charset='UTF-8'>\
<meta name='viewport' content='width=device-width, initial-scale=1.0'>\
<meta http-equiv='X-UA-Compatible' content='ie=edge'>\
<title></title>\
<style>\
img { max-width: 100%%;}\
</style>\
</head>\
<body>\
%@\
</body>\
</html>\
", self.content];
[_webView loadHTMLString:str baseURL:nil];
只需要在返回的标记文本加入头文件, 然后删除标记文本的多余字符集即可
- 更新图片适配
在<body> </body>
添加style
样式<style> img { max-width: 100%%;} </style>
即可.