let nsatrr = NSAttributedString.init(string:" " + (model.title ?? ""))
let string = NSMutableAttributedString.init(attributedString: nsatrr)
let font = UIFont.mediumSystemFont(ofSize: 14)
let textAttachment = NSTextAttachment()
textAttachment.image = UIImage.init(named: "Card_label_lto")
let paddingTop = font.lineHeight - font.pointSize
textAttachment.bounds = CGRect(x: 0, y: -paddingTop, width: 64, height: font.lineHeight)
let textAttachmentString = NSAttributedString(attachment: textAttachment)
string.insert(textAttachmentString, at: 0)
// 间距
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.minimumLineHeight = 20
paragraphStyle.maximumLineHeight = 20
string.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: string.length))
nameLabel.attributedText = string
06-24
2976
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-01
4766
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交