如何将字体设为粗体
[cell.itemContentWebView loadHTMLString:[NSString stringWithFormat:@"<div style='font-family:-apple-system','HelveticaNeue-Bold; style='font-size:24px;'>%@",object.title] baseURL:nil];
答案 0 :(得分:2)
Rafay提出您的问题
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//Font size
int fontSize = 80;
NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'", fontSize];
[webview stringByEvaluatingJavaScriptFromString:jsString];
//Font Family Style - Bold
NSString *jsWebViewFontFamilyString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.fontFamily = 'HelveticaNeue-Bold'"];
[webview stringByEvaluatingJavaScriptFromString:jsWebViewFontFamilyString];
//Font Color or web view text color
[webview stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.color = 'Green'"];
}
答案 1 :(得分:0)
在加载到webView之前,只需将标记添加到字符串前。
NSString *body = [plist objectForKey:@"foo"];
NSString *htmlString =
[NSString stringWithFormat:@"<font face='GothamRounded-Bold' size='3'>%@", body];
[webView loadHTMLString:htmlString baseURL:nil];