设为首页 加入收藏

TOP

Core Text 实现富文本显示(三)
2017-10-09 14:23:10 】 浏览:9561
Tags:Core Text 实现 文本 显示
plate.
", "fontName": "Papyrus", "fontSize": 20, "color": "0x333333" } ]

然后我们去控制器里面,把displayView添加进来,完成必要的配置,

override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        let ctView = CTDisplayView()
        view.addSubview(ctView)
        
        ctView.backgroundColor = UIColor.gray
        ctView.setX(view.x())
        ctView.setY(view.y()+64)
        ctView.setWidth(width: view.width())
        
        let config:CTFrameParserConfig = CTFrameParserConfig()
        config.width = ctView.width()
        config.lineSpace = 10
        
        let path = Bundle.main.path(forResource: "template", ofType: "json")
        let data = CTFrameParser.parserTemplateFlie(path! as NSString , config: config)
        ctView.data = data
        ctView.setHeight(height: data.height)
        
    }

最后的实现效果如下:

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Swift 了解(2) 下一篇Core Animation 动画效果介绍

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目