//个人信息
let infor:String = "你好,我叫 " + masterName + "\n" + "现任(曾任)" + masterPosition + "\n" + "是 " + masterType + "\n" + "于 " + enterDate + " 入驻"
var mutableString = NSMutableAttributedString()
mutableString = NSMutableAttributedString(string: infor, attributes: [NSFontAttributeName:UIFont.systemFont(ofSize: 14)])
//行间距
let lineSpace = NSMutableParagraphStyle.init()
lineSpace.lineSpacing = 5
mutableString.addAttribute(NSParagraphStyleAttributeName, value: lineSpace, range: NSRange(location:0,length:infor.characters.count))
//颜色
mutableString.addAttribute(NSForegroundColorAttributeName, value:WsTool.textGray(), range:NSRange(location:6,length:masterName.characters.count))
mutableString.addAttribute(NSForegroundColorAttributeName, value:WsTool.textGray(), range:NSRange(location:13 + masterName.characters.count,length:masterPosition.characters.count))
mutableString.addAttribute(NSForegroundColorAttributeName, value:WsTool.textGray(), range:NSRange(location:19 + masterName.characters.count + masterPosition.characters.count,length:masterType.characters.count))
//字体大小
mutableString.addAttribute(NSFontAttributeName, value:UIFont.systemFont(ofSize: 17), range:NSRange(location:6,length:masterName.characters.count))
mutableString.addAttribute(NSFontAttributeName, value:UIFont.systemFont(ofSize: 17), range:NSRange(location:13 + masterName.characters.count,length:masterPosition.characters.count))
mutableString.addAttribute(NSFontAttributeName, value:UIFont.systemFont(ofSize: 17), range:NSRange(location:19 + masterName.characters.count + masterPosition.characters.count,length:masterType.characters.count))
//label
let inforLabel = UILabel.init()
//多行文本
inforLabel.lineBreakMode = NSLineBreakMode.byWordWrapping
inforLabel.numberOfLines = 0
//
inforLabel.attributedText = mutableString
网友评论