系統(tǒng)為我們提供的文本屬性
/** 系統(tǒng)提供的所有富文本屬性 */
NSFontAttributeName // 設(shè)置字體
NSParagraphStyleAttributeName // 設(shè)置段落風(fēng)格
NSForegroundColorAttributeName // 設(shè)置文字顏色
NSBackgroundColorAttributeName // 設(shè)置背景顏色
NSLigatureAttributeName // 設(shè)置連體屬性
NSKernAttributeName // 設(shè)置字符間距
NSStrikethroughStyleAttributeName // 添加刪除線
NSUnderlineStyleAttributeName // 添加下劃線
NSStrokeColorAttributeName // 設(shè)置文字描邊顏色
NSStrokeWidthAttributeName // 設(shè)置文字描邊寬度
NSShadowAttributeName // 設(shè)置陰影
NSTextEffectAttributeName // 設(shè)置文本特殊效果
NSAttachmentAttributeName // 設(shè)置文本附件
NSLinkAttributeName // 設(shè)置鏈接屬性
NSBaselineOffsetAttributeName // 設(shè)置基線偏移量
NSUnderlineColorAttributeName // 添加下劃線顏色
NSStrikethroughColorAttributeName // 添加刪除線顏色
NSObliquenessAttributeName // 設(shè)置字體傾斜
NSExpansionAttributeName // 設(shè)置文本扁平
NSWritingDirectionAttributeName // 設(shè)置文字書寫方向
NSVerticalGlyphFormAttributeName // 設(shè)置文本段落排版格式
1.NSKernAttributeName: @10 調(diào)整字句 kerning 字句調(diào)整
2.NSFontAttributeName : [UIFont systemFontOfSize:_fontSize] 設(shè)置字體
3.NSForegroundColorAttributeName :[UIColor redColor] 設(shè)置文字顏色
4.NSParagraphStyleAttributeName : paragraph 設(shè)置段落樣式
5.NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
paragraph.alignment = NSTextAlignmentCenter;
6.NSBackgroundColorAttributeName: [UIColor blackColor] 設(shè)置背景顏色
7.NSStrokeColorAttributeName設(shè)置文字描邊顏色泥畅,需要和NSStrokeWidthAttributeName設(shè)置描邊寬度,這樣就能使文字空心.
NSStrokeWidthAttributeName這個屬性所對應(yīng)的值是一個 NSNumber 對象(小數(shù))瘩燥。該值改變描邊寬度(相對于字體size 的百分比)撑教。默認(rèn)為 0厕怜,即不改變纺讲。正數(shù)只改變描邊寬度驶忌。負(fù)數(shù)同時改變文字的描邊和填充寬度矛辕。例如,對于常見的空心字付魔,這個值通常為3.0聊品。
同時設(shè)置了空心的兩個屬性,并且NSStrokeWidthAttributeName屬性設(shè)置為整數(shù)几苍,文字前景色就無效果了
效果:
效果:
-
NSStrikethroughStyleAttributeName 添加刪除線翻屈,strikethrough刪除線
圖片.png
效果:
圖片.png -
NSUnderlineStyleAttributeName 添加下劃線
圖片.png
效果:
圖片.png - NSShadowAttributeName 設(shè)置陰影,單獨(dú)設(shè)置不好使妻坝,必須和其他屬性搭配才好使伸眶。
和這三個任一個都好使,NSVerticalGlyphFormAttributeName刽宪,NSObliquenessAttributeName厘贼,NSExpansionAttributeName
11.NSVerticalGlyphFormAttributeName
該屬性所對應(yīng)的值是一個 NSNumber 對象(整數(shù))。0 表示橫排文本圣拄。1 表示豎排文本嘴秸。在 iOS 中,總是使用橫排文本庇谆,0 以外的值都未定義赁遗。
圖片.png
效果:
圖片.png -
NSObliquenessAttributeName設(shè)置字體傾斜。Skew 斜
圖片.png
效果:
圖片.png -
NSExpansionAttributeName 設(shè)置文本扁平化
圖片.png
效果:
圖片.png