UIWebView 控制页面 字体 大小

来源:互联网 发布:佣兵天下的java游戏 编辑:程序博客网 时间:2024/05/01 20:52

其一:

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    // finished loading, hide the activity indicator in the status bar
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [self.guideWebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '150%'"];
}

其二:

[NSString stringWithFormat:@"<html> \n"
                                 "<head> \n"
                                 "<style type=\"text/css\"> \n"
                                 "body {font-family: \"%@\"; font-size: %f; color: %@;}\n"
                                 "</style> \n"
                                 "</head> \n"
                                 "<body>%@</body> \n"
                                 "</html>", @"宋体", fontSize,fontColor,stringValue] ;

改变字体大小颜色就:
NSString *jsString = [[NSString alloc] initWithFormat:@"document.body.style.fontSize=%f;document.body.style.color=%@",fontSize,fontColor]; 
[webView stringByEvaluatingJavaScriptFromString:jsString]; 
[jsString release];

原创粉丝点击