ios web view 解析Html格式的文本
#import "ViewController.h"
@interface ViewController ()<UIWebViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIWebView *web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
web.delegate = self;
web.backgroundColor = [UIColor whiteColor];
[web loadHTMLString:@"html格式文本" baseURL:nil];
// [web loadHTMLString:self.htmlString baseURL:nil];
[self.view addSubview:web];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// 方法中加入js代码
NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '30%'";
[webView stringByEvaluatingJavaScriptFromString:str];
}
本文标题:ios web view 解析Html格式的文本
本文链接:https://www.haomeiwen.com/subject/cyvaeqtx.html
网友评论