使用步骤
- NSMutableAttributedString初始化
- 引用方法
- 给label等赋值(attributedText)
封装方法
//传入字符串、字体 返回NSMutableAttributedString
private func appendStrWithString(str:String,font:CGFloat) -> NSMutableAttributedString {
var attributedString : NSMutableAttributedString
let attStr = NSMutableAttributedString.init(string: str, attributes: [NSFontAttributeName : UIFont.systemFontOfSize(font)])
attributedString = NSMutableAttributedString.init(attributedString: attStr)
return attributedString
}
//传入字符串、字体、颜色 返回NSMutableAttributedString
private<