开发者

How to change the font of string on webview

I am making an iPhone app in whi开发者_运维技巧ch 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.


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜