zoukankan      html  css  js  c++  java
  • UIKit控件直接显示网页文字内容

    NSString *html = @"<bold>Hello</bold> Now<br> <em>iOS</em> can create <h2>NSAttributedString</h2> from <br>HTMLs!";
        NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
        
        NSAttributedString *attrString = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUTF8StringEncoding]
                                                                          options:options documentAttributes:nil error:nil];
        CATextLayer *textLayer = [CATextLayer layer];
        textLayer.backgroundColor = [UIColor redColor].CGColor;
        textLayer.string = attrString;
        textLayer.frame = CGRectMake(10, 60, 300, 400);
        [self.view.layer addSublayer:textLayer];

    挺方便啊

  • 相关阅读:
    初试 Elastic Search
    索引分类
    Nginx
    LINQ入门
    CSS学习
    Keras 安装
    火车进站
    2016年网易笔试编程题2
    Java GC
    linux 安装 mysql
  • 原文地址:https://www.cnblogs.com/yintingting/p/5508956.html
Copyright © 2011-2022 走看看