代码之家  ›  专栏  ›  技术社区  ›  some_id

如何设置UIWebView的文本颜色?

  •  1
  • some_id  · 技术社区  · 15 年前

    我可以设置UIWebView的背景颜色,但不能设置textcolor。

    如何设置文本颜色?

    itemSummary.textColor = [UIColor colorWithRed:202 green:192 blue:146 alpha:0.75]; 
    

    但你要有一个 在非结构或联合错误的内容中请求成员“textColor”。

    5 回复  |  直到 15 年前
        1
  •  2
  •   Shinya    15 年前

        2
  •  1
  •   No one in particular    15 年前

    UIWebView没有textColor方法。我能看到的唯一类是:UITextField、UITableViewCell、UILabel和UITextField。

        3
  •  1
  •   Eshwar Chaitanya    14 年前

    您可以按照建议使用标准css样式设置颜色 here

    [self.description loadHTMLString:[NSString stringWithFormat:@"<html><body p style='color:red' text=\"#FFFFFF\" face=\"Bookman Old Style, Book Antiqua, Garamond\" size=\"5\">%@</body></html>", justifiedString] baseURL: nil];
    

    希望对你有帮助,对我也很好,谢谢:)

        4
  •  1
  •   Robert MouzmiSadiq    12 年前

    I made a method UIColor UIFont

    只需将生成的HTML弹出到webview中:

    NSString * htmlString = [MyClass htmlFromBodyString:@"an <b>example</b>"
                                               textFont:[UIFont systemFontOfSize:10]
                                              textColor:[UIColor grayColor]];
    [webView loadHTMLString:htmlString baseURL:nil];
    
        5
  •  0
  •   ChandreshKanetiya    14 年前

    不能直接在UIWebView中设置文本颜色。 在HTML文件中设置文本颜色在UIWebView中加载新的HTML文件。