NSAttributeString是一个带有属性的字符串,通过该类可以灵活的操作和呈现多种样式的文字数据。
NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc]initWithString:@"abcdefghigklmn"];
attributedStr addAttribute: value: range:对字符串中设置属性的方法,常用的属性的字符串有
NSForegroundColorAttributeName:字符的颜色 value:UIColor类型
NSBackgroundColorAttributeName:字符的背景颜色 value:UIColor类型
NSBaselineOffsetAttributeName:字符的偏移量 value:NSNumber类型
NSKernAttributeName:字符的间隔量 value:NSNumber类型
NSLinkAttributeName:带超链接 value:NSUrl类型
NSUnderlineStyleAttributeName:带下划线 value:NSNumber类型
把字符串放在label上显示出来label.attributedText = attributedStr;