Minkle Garg
Minkle Garg

Reputation: 751

How to change the font of string on webview

I am making an iPhone app in which on one of the UIWebView I am displaying a string i.e. "Example". I want to change it's font. I have used html concept also to change its font but by using this it is changing all other string which are on that UIWebView. But I want to change only "Example" font and size. How can I do this. If anyone know about this please help me.

Thanks a lot.

Upvotes: 4

Views: 863

Answers (3)

Alex Terente
Alex Terente

Reputation: 12036

test test test <span style="background: blue; color: white; font-size:30px;">test test test</span>test test test 

This is not iPhone programing related. :D

Upvotes: 0

pcmind
pcmind

Reputation: 990

Did you try somthing like :

  <font size="5" face="arial" color="red">
        This paragraph is in Arial, size 5, and in red text color.
  </font>

Visit: http://www.w3schools.com/html/html_fonts.asp

Upvotes: 0

Janak Nirmal
Janak Nirmal

Reputation: 22726

You can do it with following code, Assuming that you are putting that string between element and it is the first on the page. If it is not like that adjust as per your convenience.

NSString *strFontIncrease = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('span')[0].style.webkitTextSizeAdjust= '%f%%'",yourFontValue];
[webView stringByEvaluatingJavaScriptFromString:strFontIncrease];
[strFontIncrease release];

Check out and let me know if any doubt.

Upvotes: 3

Related Questions