iOS 字元屬性NSAttributedString描述

來源:互聯網
上載者:User

標籤:

/*

 字元屬性

 

 字元屬性可以應用於 attributed string 的文本中。

 

 NSString *const NSFontAttributeName;(字型)

 

 NSString *const NSParagraphStyleAttributeName;(段落)

 

 NSString *const NSForegroundColorAttributeName;(字型顏色)

 

 NSString *const NSBackgroundColorAttributeName;(字型背景色)

 

 NSString *const NSLigatureAttributeName;(連字號)

 

 NSString *const NSKernAttributeName;(字間距)

 

 NSString *const NSStrikethroughStyleAttributeName;(刪除線)

 

 NSString *const NSUnderlineStyleAttributeName;(底線)

 

 NSString *const NSStrokeColorAttributeName;(邊線顏色)

 

 NSString *const NSStrokeWidthAttributeName;(邊線寬度)

 

 NSString *const NSShadowAttributeName;(陰影)(橫豎排版)

 

 NSString *const NSVerticalGlyphFormAttributeName;

 

 常量

 

 1> NSFontAttributeName(字型)

 

 該屬性所對應的值是一個 UIFont 對象。該屬性用於改變一段文本的字型。如果不指定該屬性,則預設為12-point Helvetica(Neue)。

 

 2> NSParagraphStyleAttributeName(段落)

 

 該屬性所對應的值是一個 NSParagraphStyle 對象。該屬性在一段文本上應用多個屬性。如果不指定該屬性,則預設為 NSParagraphStyle 的defaultParagraphStyle 方法返回的預設段落屬性。

 

 3> NSForegroundColorAttributeName(字型顏色)

 

 該屬性所對應的值是一個 UIColor 對象。該屬性用於指定一段文本的字型顏色。如果不指定該屬性,則預設為黑色。

 

 4> NSBackgroundColorAttributeName(字型背景色)

 

 該屬性所對應的值是一個 UIColor 對象。該屬性用於指定一段文本的背景顏色。如果不指定該屬性,則預設無背景色。

 

 5> NSLigatureAttributeName(連字號)

 

 該屬性所對應的值是一個 NSNumber 對象(整數)。連體字元是指某些連在一起的字元,它們採用單個的圖元符號。0 表示沒有連體字元。1 表示使用預設的連體字元。2表示使用所有連體符號。預設值為 1(注意,iOS 不支援值為 2)。

 

 6> NSKernAttributeName(字間距)

 

 該屬性所對應的值是一個 NSNumber 對象(整數)。字母緊排指定了用於調整字距的像素點數。字母緊排的效果依賴於字型。值為 0 表示不使用字母緊排。預設值為0。

 

 7> NSStrikethroughStyleAttributeName(刪除線)

 

 該屬性所對應的值是一個 NSNumber 對象(整數)。該值指定是否在文字上加上刪除線,該值參考“Underline Style Attributes”。預設值是NSUnderlineStyleNone。

 

 8> NSUnderlineStyleAttributeName(底線)

 

 該屬性所對應的值是一個 NSNumber 對象(整數)。該值指定是否在文字上加上底線,該值參考“Underline Style Attributes”。預設值是NSUnderlineStyleNone。

 

 9> NSStrokeColorAttributeName(邊線顏色)

 

 該屬性所對應的值是一個 UIColor 對象。如果該屬性不指定(預設),則等同於 NSForegroundColorAttributeName。否則,指定為刪除線或底線顏色。更多細節見“Drawing attributedstrings that are both filled and stroked”。

 

 10> NSStrokeWidthAttributeName(邊線寬度)

 

 該屬性所對應的值是一個 NSNumber 對象(小數)。該值改變描邊寬度(相對於字型size 的百分比)。預設為 0,即不改變。正數只改變描邊寬度。負數同時改變文字的描邊和填充寬度。例如,對於常見的空心字,這個值通常為3.0。

 

 11> NSShadowAttributeName(陰影)

 

 該屬性所對應的值是一個 NSShadow 對象。預設為 nil。

 

 12> NSVerticalGlyphFormAttributeName(橫豎排版)

 

 該屬性所對應的值是一個 NSNumber 對象(整數)。0 表示橫排文本。1 表示豎排文本。在 iOS 中,總是使用橫排文本,0 以外的值都未定義。

 

 */

iOS 字元屬性NSAttributedString描述

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.