简体   繁体   中英

How to change the textcolor of UIWebnVIew iPhone

I am using webview to load the html string it loads the data but it does not change the text colour i am also changing colour but it does not get effect.

   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];

It shows default colour not the new one given

The issue is in your CSS code so simply replace

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

with

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

Hope that will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM