UILabel *pLabel = [[UILabel alloc]?initWithFrame:CGRectMake(0,100,200,100)];
pLabel.text = @"測(cè)試到嗎";
NSInteger leght = [pLabel.text length];
NSMutableAttributedString?*richText = [[NSMutableAttributedString?alloc]?initWithString:pLabel.text];
//設(shè)置特殊字段的大小,顏色,字體
[richText?addAttribute:NSFontAttributeName?value:[UIFont?boldSystemFontOfSize:16.0]?range:NSMakeRange(0, leght)];//設(shè)置字體大小
[richText?addAttribute:NSForegroundColorAttributeNamevalue:[UIColor redColor]?range:NSMakeRange(0, leght)];//設(shè)置字體顏色
[richText?addAttribute:NSObliquenessAttributeName?value:@1?range:NSMakeRange(0, leght)];//設(shè)置的是斜體
[richText?addAttribute:NSUnderlineStyleAttributeName?value:[NSNumber?numberWithInteger:NSUnderlineStyleDouble]?range:NSMakeRange(0,?leght)];//設(shè)置下劃線
[richText addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0,leght)];//設(shè)置刪除線
[richText addAttribute:NSStrikethroughColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, leght)];//設(shè)置刪除線的顏色
//屬性參數(shù)
NSFontAttributeName //字體 默認(rèn)是12號(hào)
NSParagraphStyleAttributeName//段落樣式
NSForegroundColorAttributeName//指定字體顏色
NSBackgroundColorAttributeName//字體背景顏色
NSLigatureAttributeName//連體字符
NSKernAttributeName//字距的像素
NSStrikethroughStyleAttributeName//指定字上加刪除線
NSUnderlineStyleAttributeName//指定字加下劃線
NSStrokeColorAttributeName//填充部分顏色
NSStrokeWidthAttributeName//填充寬度
NSShadowAttributeName//陰影
NSUnderlineColorAttributeName//下劃線顏色