webView 清除背景和<> 等特殊字符的自动转换

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
   
    NSString *tempString = @"&lt;div&gt;sdfsdfsdf&lt;/div&gt"; //这种形式他会自动帮我们变成<>
    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];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值