简体   繁体   中英

How to change font color, font name and font size UIWebview?

In my application I am loading HTML String which is parsed from the xml file I need to change the color, name and size of the font. To replace that I have already use the followings code but its not working

NSString *webString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%d%%'", 
                      textFontSize];
    [web stringByEvaluatingJavaScriptFromString:webString];

Is there any way then please suggest me the answer.

Thanks in Advanced!!!

Use NSAttributedString instead. Here's the docs from Apple . You can set the font type, colour, and size. You can then convert NSAttributedString back to HTML this way .

It's only available on iOS 6 and above.

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