[objc]
NSString *txtContent =@"<font color=’#ff7f00′>带顔色的字体</font>\n普通字体";
NSString *jsString = [NSString stringWithFormat:
@"<style>"
"body {font-size: 15; color: black;}"
"</style>"
"<body>%@</body>",
[txtContent stringByReplacingOccurrencesOfString:@"\n" withString:@"<br />"]];
[webView setBackgroundColor:[UIColor clearColor]];//设置webView背景色;
for (UIView *allView in [webView subviews]){
if ([allView isKindOfClass:[UIScrollView class]]){
[(UIScrollView *)allView setShowsHorizontalScrollIndicator:YES]; //水平滚动条;
[(UIScrollView *)allView setShowsVerticalScrollIndicator:YES]; //垂直滚动条;
for (UIView *shadowImgView in allView.subviews){
if ([shadowImgView isKindOfClass:[UIImageView class]]){
[shadowImgView setHidden:YES]; //隐藏图片,上下方橡皮筋效果阴影;
}
}
}
}
//加载
[webView loadHTMLString:jsString baseURL:nil];
[/objc]