var uname:String= "abcdefg hijklmn opq rst uvw xyz"
varmyMutableString =NSMutableAttributedString()
myMutableString =NSMutableAttributedString(string: uname, attributes: [NSFontAttributeName:UIFont(name:"Georgia", size:14.0)!])
添加不同字体颜色
myMutableString.addAttribute(NSForegroundColorAttributeName, value:FfontColor, range:NSRange(location:1,length:4))
//添加不同字体大小
myMutableString.addAttribute(NSFontAttributeName, value:UIFont.systemFontOfSize(12.0), range:NSRange(location:1,length:4))
Uname.attributedText= myMutableString
网友评论