// 創(chuàng)建NSMutableAttributedString 字符串
?
NSMutableAttributedString *attriString =[[NSMutableAttributedString alloc] initWithString:@"This istest"];
//把this的字體顏色變成紅色
[attriString addAttribute:(NSString*)NSForegroundColorAttributeName value:[UIColor greenColor]range:NSMakeRange(0, 4)];
[attriStringaddAttribute:(NSString *)NSForegroundColorAttributeNamevalue:(id)[UIColor redColor] range:NSMakeRange(5, 2)];
//給this添加刪除線敦锌,value可以指定的枚舉中選擇
[attriString addAttribute:(NSString*)NSStrikethroughStyleAttributeName value:(id)[NSNumbernumberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0,4)];
//給this添加雙下劃線,
[attriStringaddAttribute:(NSString *)NSUnderlineStyleAttributeNamevalue:(id)[NSNumber numberWithInt:NSUnderlineStyleDouble]range:NSMakeRange(0, 4)];
UILabel*label = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 100,60)];
[self.viewaddSubview:label];
label.attributedText = attriString;
PS: 有疑問歡迎留言馒疹。