0

我正在使用 webview 加载它加载数据的 html 字符串,但它不会改变文本颜色我也在改变颜色,但它没有生效。

   NSString *myDescriptionHTML = [NSString stringWithFormat:@"<html> \n"
                               "<head> \n"
                               "<style type=\"text/css\"> \n"
                               "body {font-family: \"%@\"; font-size: %@; text-colour:red}\n"
                               "</style> \n"
                               "</head> \n"
                               "<body>%@</body> \n"
                               "</html>", @"helvetica", [NSNumber numberWithInt:18],  texts];

它显示默认颜色而不是给定的新颜色

4

1 回答 1

3

问题出在您的 CSS 代码中,因此只需替换

 "body {font-family: \"%@\"; font-size: %@; text-colour:red}\n"

 "body {font-family: \"%@\"; font-size: %@; color:red}\n"

希望这会奏效

于 2013-10-25T07:40:23.317 回答