How to determine link text color in UIWebView

I have a string text string that can contain a web link . I load it into a UIWebView using loadHTMLString and notice that, for example, the font style and size are incorrect. I can't find anything else, so I am inserting text inside an ad hoc HTML document using CSS (this is REALLY the only way):

NSString *myHtml = [NSString stringWithFormat: @"<html><head>" "<style type=\"text/css\">" "body{" "font-family: Helvetica;" "font-size: 20px;" "a {color: #FFF;}" "},</style>" "</head><body>%@</body></html>", myText]; [self.myWebView loadHTMLString:myHtml baseURL:nil]; 

Problem: I just can’t figure out how to change the link style . I tried {color: #fff;}, *: link {color: #fff;} etc., which they don’t even remember. Nothing has changed regarding the default look of links! Not color, not size, not background, nothing!

Any tips on how to have any control over how the links look? Will using javaScript be the only option?

+4
source share
1 answer

You have enclosed a rule in a body rule. Move it outside.

+6
source

Source: https://habr.com/ru/post/1300382/


All Articles