NSString *jsString = [NSString stringWithFormat:@"这个是测试内容字体", fontSize, fontFamily, fontColor, htmlText];
[_infoTextView loadHTMLString:jsString baseURL:nil];
iOS赵冬冬 14:23:06
?
meet 14:23:06
这样的代码,你给我测试下,看一看什么样子
iOS赵冬冬 14:35:29
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIWebView *WebView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 100, 300, 300)];
// WebView.delegate = self;
[self.view addSubview:WebView];
float fontSize = 20;
NSString *fontColor = @"red";
NSString *fontFamily = @"Times New Roman";
NSString *htmlText = @"Do any additional setup after loading the view, typically from a nib.";
NSString *jsString = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<style type=\"text/css\"> \n"
"body {font-size: %f; font-family: \"%@\"; color: %@;}\n"
"</style> \n"
"</head> \n"
"<body>%@</body> \n"
"</html>", fontSize, fontFamily, fontColor, htmlText];
[WebView loadHTMLString:jsString baseURL:nil];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView;
{
float fontSize = 20;
NSString *fontColor = @"";
NSString *jsString = [[NSString alloc] initWithFormat:@"document.body.style.fontSize=%f;document.body.style.color=%@",fontSize,fontColor];
[webView stringByEvaluatingJavaScriptFromString:jsString];
}