简单图文混排swift
来源:互联网 发布:pc录视频软件 编辑:程序博客网 时间:2024/05/21 06:48
//需求 邱学伟是大帅哥(加个笑脸图片) 邱学伟:红色背景绿色字体加粗显示 是:蓝色字体 10号小字体 大帅哥:灰色42号字体
fileprivate func FuWenBenDemo() {
//定义富文本即有格式的字符串 let attributedStrM : NSMutableAttributedString = NSMutableAttributedString() //邱学伟 let qiuxuewei : NSAttributedString = NSAttributedString(string: "邱学伟", attributes: [ NSBackgroundColorAttributeName : UIColor.red,NSForegroundColorAttributeName : UIColor.green, NSFontAttributeName : UIFont.boldSystemFont(ofSize: 28.0)]) //(string: "邱学伟") //是 let shi : NSAttributedString = NSAttributedString(string: "是", attributes: [NSForegroundColorAttributeName : UIColor.blue, NSFontAttributeName : UIFont.systemFont(ofSize: 10.0)]) //大帅哥 let dashuaige : NSAttributedString = NSAttributedString(string: "大帅哥", attributes: [NSForegroundColorAttributeName : UIColor.lightGray, NSFontAttributeName : UIFont.systemFont(ofSize: 42.0)]) //笑脸图片 let smileImage : UIImage = UIImage(named: "d_hehe")! let textAttachment : NSTextAttachment = NSTextAttachment() textAttachment.image = smileImage textAttachment.bounds = CGRect(x: 0, y: -4, width: 22, height: 22) attributedStrM.append(qiuxuewei) attributedStrM.append(shi) attributedStrM.append(dashuaige) attributedStrM.append(NSAttributedString(attachment: textAttachment)) label.attributedText = attributedStrM}
阅读全文
0 0
- 简单图文混排swift
- swift实现简单的图文混排
- SWIFT实现图文混排
- 图文混排简单使用
- iOS 图文混排(swift)
- 一个简单的图文混排控件
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS实现简单图文混排效果
- iOS 简单图文混排01
- Matlab 绘制球面
- 快速排序实现之递归与非递归
- 关于php 防止SQL注入的一些总结
- LINUX之inode理解
- 代码干货|小白一夜变身前端大神,究竟经历了什么
- 简单图文混排swift
- QT中登陆界面的编写
- C#写入和读出文本文件
- 9_javaweb_cookie_基本原理
- 莫比乌斯函数(数论)(转载+原创)
- 小程序实战--仿bilibil(哔哩哔哩)小程序
- 学习啊学习
- C# 访问共享文件夹或者磁盘(需要用户名密码)
- java序列化小案例