在Iphone SDK中更改Web视图的字体大小

我已经实现了feedparsing并获取内容为一个string。 现在,我正在通过它编写html文件。 在Web视图中加载该HTML。 我的网页视图是表格视图单元格中的子视图。

在这里输入图像说明

但现在我想改变网页浏览内容的字体大小,所以用户可以看到一些细节。

我的HTML代码是:

NSString * postHTML=[[_parseResults objectAtIndex:indexPath.row]valueForKey:@"summary"]; NSString *close =[NSString stringWithFormat:@"</body></html>"]; NSString *HTMLString = [NSString stringWithFormat:@"%@%@", postHTML,close]; [Web_view loadHTMLString:HTMLString baseURL:nil]; [cell.contentView addSubview:Web_view]; return cell; 

我怎样才能改变网页浏览内容的字体大小?

 [myWeb loadHTMLString:[NSString stringWithFormat:@"<div style='text-align:justify; font-size:45px;font-family:HelveticaNeue-CondensedBold;color:#0000;'>%@%@",postHTML,close] baseURL:nil]; 

您可以在代码中以font-size:size设置字体大小。

试试这个..我知道这是工作或不!

在UIWebView中,您可以在传递数据时使用所有HTML标记。

 [WebView loadHTMLString:[NSString stringWithFormat:@"<div style='text-align:justify; font-size:44px;font-family:HelveticaNeue-CondensedBold;color:#ffff;'>%@",Data] baseURL:nil]; 

使用上面的代码,其中“数据”将是您的内容。

谢谢,

Hemang。

在你的html中设置

 NSString *string = [NSString stringWithFormat: @"<html> \n" "<head> \n" "<style type=\"text/css\"> \n" "body {font-family: \"%@\"; font-size: %@;}\n" "</style> \n" "</head> \n" "<body>%@</body> \n" "</html>",@"Helvetica",[NSNumber numberWithInt:17], @"<p><i>My data</p>"];