4

I am using this line of code to set the font and the size of the text.But this is not working

NSString *abc=@"<html><body style=\"font-family:Verdana; font-size:12px; color:#000000;\"></body></html>";
    [msgWebView setCustomTextEncodingName:abc];

Please let me know how can i set the font style of text in a WebView.

Nipun35
  • 275
  • 2
  • 9
  • possible duplicate of [iPhone Development - Setting UIWebView font](http://stackoverflow.com/questions/449773/iphone-development-setting-uiwebview-font) – TeaCupApp Jun 01 '12 at 06:47
  • put the style tag in the 'head' tag and not in the 'body' – shannoga Jun 01 '12 at 06:58
  • @shannoga..I am now using this but still it is not working..and one more thing to say is that i am not showing any text in the webView,the user will enter text in it and i want that the text entered by user should have this font style.. NSString *abc=[NSString stringWithFormat:@" \n" " \n" " \n" " \n" " \n" "", @"Verdana",[NSNumber numberWithInt:20]]; [msgWebView setCustomTextEncodingName:abc]; – Nipun35 Jun 01 '12 at 07:11
  • @NareshSharma yes brother i will :) – Nipun35 Jun 05 '12 at 05:45

1 Answers1

3

I think you're approaching it the wrong way. Another way is:

[[msgWebView preferences] setDefaultFontSize:12];
[[msgWebView preferences] setStandardFontFamily:@"Verdana"]; 
Vervious
  • 5,559
  • 3
  • 38
  • 57