kagmanoj
kagmanoj

Reputation: 5388

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!!!

Upvotes: 0

Views: 883

Answers (1)

Enrico Susatyo
Enrico Susatyo

Reputation: 19790

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.

Upvotes: 1

Related Questions