Nhu Nguyen
Nhu Nguyen

Reputation: 874

Set font size content UIWebview

I built an application to read mail on the ipad, when displayed html body content to UIWebView the font size it is not uniform, I can not adjust the font size as all the other applications MailBox, 'Gmail'..

I use: html { -webkit-text-size-adjust: none; /* Never autoresize text */ }
but does not solve the problem, how to fix it?

Upvotes: 2

Views: 1286

Answers (2)

user3150919
user3150919

Reputation:

You can set font size of webview , like

NSString *fontsize;  
fontsize=20px;


NSString *WebviewString;  
WebviewString=@"xyz";

Put the value of fontsize and WebviewString in this:

 [MywebView loadHTMLString:[NSString stringWithFormat:@"<div style='text-align:justify; font-size:%@;font-family:Helvetica;color:#ffff;'>%@",fontsize,WebviewString] baseURL:nil];

Hope it will helpyou.

Upvotes: 0

Agent Chocks.
Agent Chocks.

Reputation: 1312

try this one it worked for me

- (void)webViewDidFinishLoad:(UIWebView *)wView {
    [wView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '50%'"];
    [wView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.zoom= '0.5'"];
}

Upvotes: 2

Related Questions