- (void)viewDidLoad
{
??? [super viewDidLoad];
??? // Do any additional setup after loading the view, typically from a nib.
???
??? NSString *tempString = @"<div>sdfsdfsdf</div>"; //这种形式他会自动帮我们变成<>
??? NSString *tempString2 = @"<div>sdfsdfsdf</div>"; //这种形式他会自动帮我们去掉<div>等。
??? [self.myWebView loadHTMLString:tempString2 baseURL:nil];
??? self.myWebView.backgroundColor = [UIColor clearColor];
??? [self clearWebViewBackgroundWithColor];
??? self.myWebView.opaque = NO;
}
- (void)clearWebViewBackgroundWithColor{//下面这个方法是去除滚动的时候的背景。
??? NSLog(@"%d===",[[self.myWebView subviews]count]);
???? NSLog(@"%d===",[[[[self.myWebView subviews]objectAtIndex:0]subviews]count]);
???
??? for (UIView *view in [self.myWebView subviews]){
??????? if ([view isKindOfClass:[UIScrollView class]]){
??????????? for (UIView *shadowView in view.subviews){
??????????????? // 上下滚动出边界时的黑色的图片 也就是拖拽后的上下阴影
??????????????? if ([shadowView isKindOfClass:[UIImageView class]]){
??????????????????? shadowView.hidden = YES;
??????????????? }
??????????? }
??????? }
??? }
}
?
?
?
?
改变UIwebView 的字体颜色和大小。
?
?NSString *tempString2 = @"<div>sdfsdfsdf</div>";
???
??? NSString *jsString = [NSString stringWithFormat:@"<html> \n"
????????????????????????? "<head> \n"
????????????????????????? "<style type=\"text/css\"> \n"
????????????????????????? "body {font-size: %d; font-family: \"%@\"; color: %@;font-weight:bold;}\n"
????????????????????????? "</style> \n"
????????????????????????? "</head> \n"
????????????????????????? "<body>%@</body> \n"
????????????????????????? "</html>", 33, @"Arail", @"red", tempString2];
??? [self.myWebView loadHTMLString:jsString baseURL:nil];