html - 在iOS中使UIWebview的字体加粗

标签 html ios objective-c uiwebview

如何将字体设置为粗体

[cell.itemContentWebView loadHTMLString:[NSString stringWithFormat:@"<div style='font-family:-apple-system','HelveticaNeue-Bold; style='font-size:24px;'>%@",object.title] baseURL:nil];

最佳答案

拉斐回答你的问题

- (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'"]; 

}

关于html - 在iOS中使UIWebview的字体加粗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33417158/

相关文章:

ios - 状态栏颜色 : preferredStatusBarStyle doesn't work

ios - UITableView,不可见区域的另一个单元格有一个复选标记,而可见区域的一个单元格被触摸

ios - 推送通知,是否可以让推送通知在应用程序打开时也向下滑动?

ios - 创建一个类来获取所有按钮委托(delegate)

ios - 继续 : what happens to the controller instance that calls the seque?

html - 谷歌结帐。可以在登录前显示运费吗?

html - 调整图像悬停从中心向外而不是从左侧向外

javascript - 提交表单 onload 不起作用

ios - objective-c 中的 Sqlite3 数据库 [需要建议]

html - 为 .each 循环中的一个条目显示带有表显示值的模态