NSFontAttributeName(字體)
UIFont, default Helvetica(Neue) 12
該屬性所對(duì)應(yīng)的值是一個(gè) UIFont 對(duì)象。該屬性用于改變一段文本的字體。
NSParagraphStyleAttributeName(段落)
NSParagraphStyle, default defaultParagraphStyle
該屬性所對(duì)應(yīng)的值是一個(gè) NSParagraphStyle 對(duì)象。該屬性在一段文本上應(yīng)用多個(gè)屬性(居中,換行模式,間距等樣式)。如果不指定該屬性,則默認(rèn)為 NSParagraphStyle 的 defaultParagraphStyle 方法返回的默認(rèn)段落屬性。
NSForegroundColorAttributeName(字體顏色)
UIColor, default blackColor
該屬性所對(duì)應(yīng)的值是一個(gè) UIColor 對(duì)象。該屬性用于指定一段文本的字體顏色。如果不指定該屬性,則默認(rèn)為黑色。
注意:
NSForegroundColorAttributeName 設(shè)置的顏色與 UILabel 的 textColor 屬性設(shè)置的顏色在地位上是相等的,與 NSBackgroundColorAttributeName 地位上也相等,誰最后賦值,最終顯示的就是誰的顏色,但是textColor屬性可以與 NSBackgroundColorAttributeName 屬性可疊加。
NSBackgroundColorAttributeName(字體背景色)
UIColor, default nil: no background
該屬性所對(duì)應(yīng)的值是一個(gè) UIColor 對(duì)象。該屬性用于指定一段文本的背景顏色。如果不指定該屬性,則默認(rèn)無背景色。
NSLigatureAttributeName(連字符)
NSNumber containing integer, default 1: default ligatures, 0: no ligatures
該屬性所對(duì)應(yīng)的值是一個(gè) NSNumber 對(duì)象(整數(shù))。連體字符是指某些連在一起的字符,它們采用單個(gè)的圖元符號(hào)。0 表示沒有連體字符。1 表示使用默認(rèn)的連體字符。2表示使用所有連體符號(hào)。默認(rèn)值為 1(注意,iOS 不支持值為 2)。
NSKernAttributeName(字符間距)
NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.
NSKernAttributeName 設(shè)定字符間距,取值為 NSNumber 對(duì)象(整數(shù)),正值間距加寬,負(fù)值間距變窄
NSStrikethroughStyleAttributeName(刪除線)
NSNumber containing integer, default 0: no strikethrough
NSStrikethroughStyleAttributeName 設(shè)置刪除線,取值為 NSNumber 對(duì)象(整數(shù)),枚舉常量 NSUnderlineStyle 中的值:
typedef NS_ENUM(NSInteger, NSUnderlineStyle) {
NSUnderlineStyleNone = 0x00,// 不設(shè)置刪除線
NSUnderlineStyleSingle = 0x01,// (──────)細(xì)單實(shí)線
NSUnderlineStyleThick NS_ENUM_AVAILABLE(10_0, 7_0) = 0x02,// (━━━━━━━)粗單實(shí)線
NSUnderlineStyleDouble NS_ENUM_AVAILABLE(10_0, 7_0) = 0x09,// (══════)細(xì)雙實(shí)線
NSUnderlinePatternSolid NS_ENUM_AVAILABLE(10_0, 7_0) = 0x0000,// (────────)
NSUnderlinePatternDot NS_ENUM_AVAILABLE(10_0, 7_0) = 0x0100,// (? ? ? ? ? ?)
NSUnderlinePatternDash NS_ENUM_AVAILABLE(10_0, 7_0) = 0x0200,// (— — — —)
NSUnderlinePatternDashDot NS_ENUM_AVAILABLE(10_0, 7_0) = 0x0300,// (— ? — ? — ?)
NSUnderlinePatternDashDotDot NS_ENUM_AVAILABLE(10_0, 7_0) = 0x0400,// (— ? ? — ? ?)
NSUnderlineByWord NS_ENUM_AVAILABLE(10_0, 7_0) = 0x8000// (????????????)
} NS_ENUM_AVAILABLE(10_0, 6_0);
NSUnderlineStyleAttributeName(下劃線)
NSNumber containing integer, default 0: no underline
該屬性所對(duì)應(yīng)的值是一個(gè) NSNumber 對(duì)象(整數(shù))。該值指定是否在文字上加上下劃線,該值參考“Underline Style Attributes”。默認(rèn)值是 NSUnderlineStyleNone。
NSStrokeColorAttributeName(文字描邊顏色)
UIColor, default nil: same as foreground color
設(shè)置文字描邊顏色,需要和NSStrokeWidthAttributeName設(shè)置描邊寬度,這樣就能使文字空心.
NSStrokeWidthAttributeName(文字描邊寬度)
NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)
NSStrokeWidthAttributeName 這個(gè)屬性所對(duì)應(yīng)的值是一個(gè) NSNumber 對(duì)象(小數(shù))。該值改變筆畫寬度(相對(duì)于字體 size 的百分比),負(fù)值填充效果,正值中空效果,默認(rèn)為 0,即不改變。正數(shù)只改變描邊寬度。負(fù)數(shù)同時(shí)改變文字的描邊和填充寬度。例如,對(duì)于常見的空心字,這個(gè)值通常為 3.0。
同時(shí)設(shè)置了空心的兩個(gè)屬性,并且 NSStrokeWidthAttributeName 屬性設(shè)置為整數(shù),文字前景色就無效果了。
NSShadowAttributeName(陰影)
NSShadow, default nil: no shadow
該屬性所對(duì)應(yīng)的值是一個(gè) NSShadow 對(duì)象。默認(rèn)為 nil。單獨(dú)設(shè)置不好使,和這三個(gè)任一個(gè)都好使,NSVerticalGlyphFormAttributeName,NSObliquenessAttributeName,NSExpansionAttributeName
NSTextEffectAttributeName(效果屬性)
NSString, default nil: no text effect
該屬性所對(duì)應(yīng)的值是一個(gè) NSString 對(duì)象,默認(rèn)為 nil,表示無文字效果。
NSTextEffectLetterpressStyle:圖形文字凸版印刷效果。
NSAttachmentAttributeName(附件屬性)
NSTextAttachment, default nil
NSLinkAttributeName(鏈接屬性)
NSURL (preferred) or NSString
NSBaselineOffsetAttributeName(基線偏移量)
NSNumber containing floating point value, in points; offset from baseline, default 0
NSUnderlineColorAttributeName(下劃線顏色)
UIColor, default nil: same as foreground color
NSUnderlineColorAttributeName 設(shè)置下劃線顏色,取值為 UIColor 對(duì)象,默認(rèn)值為黑色
NSStrikethroughColorAttributeName(刪除線顏色)
UIColor, default nil: same as foreground color
NSStrikethroughColorAttributeName 設(shè)置刪除線顏色,取值為 UIColor 對(duì)象,默認(rèn)值為黑色
NSObliquenessAttributeName(字體傾斜)
NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew
NSExpansionAttributeName (字體扁平化)
NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion
NSWritingDirectionAttributeName(書寫方向?qū)傩裕?/h3>
NSArray of NSNumbers representing the nested levels of writing direction overrides as defined by Unicode LRE, RLE, LRO, and RLO characters. The control characters can be obtained by masking NSWritingDirection and NSWritingDirectionFormatType values. LRE: NSWritingDirectionLeftToRight|NSWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSWritingDirectionOverride,
NSVerticalGlyphFormAttributeName(橫豎排版)
An NSNumber containing an integer value. 0 means horizontal text. 1 indicates vertical text. If not specified, it could follow higher-level vertical orientation settings. Currently on iOS, it's always horizontal. The behavior for any other value is undefined.
NSArray of NSNumbers representing the nested levels of writing direction overrides as defined by Unicode LRE, RLE, LRO, and RLO characters. The control characters can be obtained by masking NSWritingDirection and NSWritingDirectionFormatType values. LRE: NSWritingDirectionLeftToRight|NSWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSWritingDirectionOverride,
An NSNumber containing an integer value. 0 means horizontal text. 1 indicates vertical text. If not specified, it could follow higher-level vertical orientation settings. Currently on iOS, it's always horizontal. The behavior for any other value is undefined.
設(shè)置文字垂直方向、水平方向顯示,該屬性所對(duì)應(yīng)的值是一個(gè) NSNumber 對(duì)象(整數(shù))。0 表示橫排文本。1 表示豎排文本。在 iOS 中,總是使用橫排文本,0 以外的值都未定義。