In my application I am loading HTML String which is coming from server, the string already contain font color and font size but I need to change the color and size of the font. To replace that I have already use the followings code but its not working.
UIWebView *webView=[[UIWebView alloc]initWithFrame:CGRectMake(0,0, 550, 200)];
[webView loadHTMLString:[NSString stringWithFormat:@"<div style='text-align:justify; font-size:16px;font-family:HelveticaNeue-Condensed;color:#ffff;'>%@",title] baseURL:nil];
[webView setOpaque:NO];
webView.delegate = self;
[webView setBackgroundColor:[UIColor clearColor]];
[self addSubview:webView];
Is there is any other way to change it? Please suggest me the answer.
I used following code
NSString *embedHTML = @"<html><body bgcolor=#EAEAEA><font face='Myriad Pro' size='3'><meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=5.0; user-scalable=YES'/>";///You can set your colour using font tag
NSString *endHtml=@"</font></body></html>";
NSString *strDes=[NSString stringWithFormat:@"%@%@%@",embedHTML,videoShareObject.strDescription,endHtml];
[self.webViewObj loadHTMLString:strDes baseURL:nil];
NSString *string = [NSString stringWithFormat:@"document.body.style.zoom = %f;", fontSizeSlider.value]; //I used the Sliderbar, You can set your font size.
[webViewObj stringByEvaluatingJavaScriptFromString:string];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.