zoukankan      html  css  js  c++  java
  • UIWebView控件中 字体大小和字体样式的修改

    修改UIWebView控件中字体的样式:

    NSString *htmlString = [NSString stringWithContentsOfFile:self.webPath encoding:NSUTF8StringEncoding error:nil];
    UIFont *font = [UIFont systemFontOfSize:12];
    NSString *newHtmlString = [NSString stringWithFormat:@"<font face='%@' >%@", font.fontName,htmlString];
    [self.myWebView loadHTMLString:newHtmlString baseURL:[NSURL URLWithString:self.webPath]];

    其中self.webPath 为本地网页的路径。

    修改UIWebView控件中字体的大小:

    NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '60%'";
    [self.myWebView stringByEvaluatingJavaScriptFromString:str];

    可以根据需要修改百分比。

  • 相关阅读:
    babel的使用及安装配置
    npm install卡顿问题
    盒模型
    安全性
    字符串方法
    vue
    CSS3
    重载运算符
    装箱拆箱
    模板库
  • 原文地址:https://www.cnblogs.com/ceasar/p/6525170.html
Copyright © 2011-2022 走看看