前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >IOS 使用Text Kit编排图文

IOS 使用Text Kit编排图文

作者头像
用户5760343
发布2019-07-10 15:47:53
4600
发布2019-07-10 15:47:53
举报
文章被收录于专栏:sktj

1 let textView = UITextView(frame:CGRect(x:20, y: 40, width:280, height:500)) 2 textView.backgroundColor = UIColor.brown 3 self.view.addSubview(textView) 4 5 let textStorage = textView.textStorage 6 let path = Bundle.main.url(forResource:“word”, withExtension:“txt”) 7 do { 8 let string = try String(contentsOf:path!) 9 textStorage.replaceCharacters(in:NSRange(location: 0,length:0), with:string) 10 } 11 catch{ 12 print(“读取文件错误!”) 13 } 14 let image = UIImage(named:“Tea”) 15 let imageView = UIImageView(image:image) 16 let rect = CGRect(x:80, y:80, width:150, height:

17 imageView.frame = rect 18 19 imageView.layer.cornerRadius = 75 20 imageView.layer.masksToBounds = true 21 imageView.layer.borderWidth = 10 22 self.view.addSubview(imageView) 23 var frame = textView.convert(imageView.bounds, from:imageView) 24 frame.origin.x -= textView.textContainerInset.left; 25 frame.origin.y -= textView.textContainerInset.top; 26 27 let path2 = UIBezierPath(ovalIn:frame) 28 textView.textContainer.exclusionPaths = [path2]

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019.07.06 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档