有head的HTML
1.拼接HTML
2.創(chuàng)建webview后? 用這個(gè)方法加載HTML
[self.webView loadHTMLString:[self reSizeImageWithHTMLHadHead:HTML_HAD_HEAD] baseURL:nil];
3.設(shè)置它的寬度? --等寬的 ([self reSizeImageWithHTMLHadHead:HTML_HAD_HEAD]這個(gè)方法)
有head的 (沒有head沒處理 )
- (NSString *)reSizeImageWithHTMLHadHead:(NSString *)html {? ?
CGFloat with=[UIScreen mainScreen].bounds.size.width;? ? ? ?
return [HTML_HAD_HEAD stringByReplacingOccurrencesOfString:@"" withString:[NSString stringWithFormat:@"img{width:%fpx !important;}body{margin:0;}",with]];? ? }
3.1:width:%fpx? 設(shè)置寬度
3.2:!important? 自動(dòng)縮放等比例? 按請(qǐng)求到的數(shù)據(jù)
3.3:body{margin:0;}? 防止內(nèi)邊距影響視覺效果? 四周出現(xiàn)白色空白區(qū)域
?