`

UIWebView

 
阅读更多
http://hi.baidu.com/wei_1123/item/a11f65df35ca4ee63cc2cbd8

http://unmi.cc/uiwebview-replace-uitextview-line-height

图片URL:
http://gaohaijun.blog.163.com/blog/static/176698271201110133338742/

一些JS的操作:
http://www.cnblogs.com/superhappy/archive/2012/12/04/2801929.html


        self.saying = [[UIWebView alloc] initWithFrame:CGRectMake(6, 84, 314, 320)];
        self.saying.opaque = NO;
        self.saying.backgroundColor = [UIColor clearColor];
        self.saying.dataDetectorTypes = UIDataDetectorTypeNone;
        [self addSubview:self.saying];
       
//        remove shadow view when drag web view
        for (UIView *subView in [self.saying subviews])
        {
            if ([subView isKindOfClass:[UIScrollView class]])
            {
                for (UIView *shadowView in [subView subviews])
                {
                    if ([shadowView isKindOfClass:[UIImageView class]])
                    { shadowView.hidden = YES; }
                }
            }
        }
       
        //backgroud-color:transparent 结合最前面的两行代码指定的属性就真正使得 WebView 的背景透明了
        //font:16px/18px 就是设置字体大小为 16px, 行间距为 18px,也可用  line-height: 18px 单独设置行间距
        //Custom-Font-Name 就是前面在项目中加上的字体文件所对应的字体名称了
        //  margin:0;background-color:transparent;font:20px/26px Custom-Font-Name
NSString *css =
        @"<style>"
        "body{margin:0;background-color:transparent;color:#ffffff;text-indent:40px;font:20px/30px Custom-Font-Name}"
        "p{margin:0px;padding:0;}"
        "</style>";
        NSString *htmlString = [css stringByAppendingFormat:@"%@", text];
        [self.saying loadHTMLString:htmlString baseURL:nil];
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics