修改UIWebView控件中字体的样式:
? 1 2 3 4 NSString *htmlString = [NSString stringWithContentsOfFile:self.webPath encoding:NSUTF8StringEncoding error:nil]; UIFont *font = [UIFont systemFontOfSize:12]; NSString *newHtmlString = [NSString stringWithFormat:@"<font face='%@' >%@", font.fontName,htmlString]; [self.myWebView loadHTMLString:newHtmlString baseURL:[NSURL URLWithString:self.webPath]];其中self.webPath 为本地网页的路径。
修改UIWebView控件中字体的大小:
? 1 2 NSString *str = @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '60%'"; [self.myWebView stringByEvaluatingJavaScriptFromString:str];可以根据需要修改百分比。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持服务器之家!
原文链接:http://www.cnblogs.com/ceasar/p/6525170.html