콘텐츠에 CSS
코드를 추가하는 것이 좋습니다.
나는이 한 번해야했다, 여기 내 코드의 예는 다음과 같습니다
NSString *systemFont = [[[UIFont systemFontOfSize:11.f] description] fontCSS];
NSString *boldFont = [[[UIFont boldSystemFontOfSize:12.f] description] fontCSS];
// The above fonts can be changed to your liking.
NSString *oldContent = ___; // This is the html content that was loaded.
NSString *content = [NSString stringWithFormat:@"<html><head>\
<style>\
img,iframe{max-width:100%%; width:auto; height:auto; display:block; margin-left:auto; margin-right:auto; margin-bottom:20px}\
body{%@; margin-left:24px; margin-right:24px; margin-bottom:24px}\
strong{%@}\
</style>\
</head><body>%@</body></html>", systemFont, boldFont, oldContent];
지금 당신은 당신의
webview
으로
content
변수를 사용합니다.
-(NSString *)fontCSS
{
NSRange range = [self rangeOfString:@"font-family"];
return [self substringFromIndex:range.location];
}
당신이 웹보기에 htmlstring를로드하는 다음과 같이
fontCSS
방법은있는 NSString 범주에있어, 무엇입니까? – Kuldeep로드 중 URL [self.wkWebView loadRequest : [NSURLRequest requestWithURL : pageUrl]]; – Angel