NSAttributedString.h

UIKIT_EXTERN NSString *const NSFontAttributeName NS_AVAILABLE_IOS(6_0);                // UIFont, default Helvetica(Neue) 12
UIKIT_EXTERN NSString *const NSParagraphStyleAttributeName NS_AVAILABLE_IOS(6_0);      // NSParagraphStyle, default defaultParagraphStyle
UIKIT_EXTERN NSString *const NSForegroundColorAttributeName NS_AVAILABLE_IOS(6_0);     // UIColor, default blackColor
UIKIT_EXTERN NSString *const NSBackgroundColorAttributeName NS_AVAILABLE_IOS(6_0);     // UIColor, default nil: no background
UIKIT_EXTERN NSString *const NSLigatureAttributeName NS_AVAILABLE_IOS(6_0);            // NSNumber containing integer, default 1: default ligatures, 0: no ligatures
UIKIT_EXTERN NSString *const NSKernAttributeName NS_AVAILABLE_IOS(6_0);                // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.
UIKIT_EXTERN NSString *const NSStrikethroughStyleAttributeName NS_AVAILABLE_IOS(6_0);  // NSNumber containing integer, default 0: no strikethrough
UIKIT_EXTERN NSString *const NSUnderlineStyleAttributeName NS_AVAILABLE_IOS(6_0);      // NSNumber containing integer, default 0: no underline
UIKIT_EXTERN NSString *const NSStrokeColorAttributeName NS_AVAILABLE_IOS(6_0);         // UIColor, default nil: same as foreground color
UIKIT_EXTERN NSString *const NSStrokeWidthAttributeName NS_AVAILABLE_IOS(6_0);         // 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)
UIKIT_EXTERN NSString *const NSShadowAttributeName NS_AVAILABLE_IOS(6_0);              // NSShadow, default nil: no shadow
UIKIT_EXTERN NSString *const NSTextEffectAttributeName NS_AVAILABLE_IOS(7_0);          // NSString, default nil: no text effect

UIKIT_EXTERN NSString *const NSAttachmentAttributeName NS_AVAILABLE_IOS(7_0);          // NSTextAttachment, default nil
UIKIT_EXTERN NSString *const NSLinkAttributeName NS_AVAILABLE_IOS(7_0);                // NSURL (preferred) or NSString
UIKIT_EXTERN NSString *const NSBaselineOffsetAttributeName NS_AVAILABLE_IOS(7_0);      // NSNumber containing floating point value, in points; offset from baseline, default 0
UIKIT_EXTERN NSString *const NSUnderlineColorAttributeName NS_AVAILABLE_IOS(7_0);      // UIColor, default nil: same as foreground color
UIKIT_EXTERN NSString *const NSStrikethroughColorAttributeName NS_AVAILABLE_IOS(7_0);  // UIColor, default nil: same as foreground color
UIKIT_EXTERN NSString *const NSObliquenessAttributeName NS_AVAILABLE_IOS(7_0);         // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew
UIKIT_EXTERN NSString *const NSExpansionAttributeName NS_AVAILABLE_IOS(7_0);           // NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion

UIKIT_EXTERN NSString *const NSWritingDirectionAttributeName NS_AVAILABLE_IOS(7_0);    // 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 NSTextWritingDirection values.  LRE: NSWritingDirectionLeftToRight|NSTextWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSTextWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSTextWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSTextWritingDirectionOverride,

UIKIT_EXTERN NSString *const NSVerticalGlyphFormAttributeName NS_AVAILABLE_IOS(6_0);   // 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.

<a>

// This defines currently supported values for NSUnderlineStyleAttributeName and NSStrikethroughStyleAttributeName.

typedef NS_ENUM(NSInteger, NSUnderlineStyle) {
    NSUnderlineStyleNone                                = 0x00,
    NSUnderlineStyleSingle                              = 0x01,
    NSUnderlineStyleThick NS_ENUM_AVAILABLE_IOS(7_0)    = 0x02,
    NSUnderlineStyleDouble NS_ENUM_AVAILABLE_IOS(7_0)   = 0x09,
    NSUnderlinePatternSolid NS_ENUM_AVAILABLE_IOS(7_0)      = 0x0000,
    NSUnderlinePatternDot NS_ENUM_AVAILABLE_IOS(7_0)        = 0x0100,
    NSUnderlinePatternDash NS_ENUM_AVAILABLE_IOS(7_0)       = 0x0200,
    NSUnderlinePatternDashDot NS_ENUM_AVAILABLE_IOS(7_0)    = 0x0300,
    NSUnderlinePatternDashDotDot NS_ENUM_AVAILABLE_IOS(7_0) = 0x0400,
    NSUnderlineByWord NS_ENUM_AVAILABLE_IOS(7_0) = 0x8000
} NS_ENUM_AVAILABLE_IOS(6_0);

<a>

// NSTextWritingDirection values used by NSWritingDirectionAttributeName. Can specify the formatting controls defined by Unicode Bidirectional Algorithm.
*/

typedef NS_ENUM(NSInteger, NSTextWritingDirection) {
    NSTextWritingDirectionEmbedding     = (0 << 1),
    NSTextWritingDirectionOverride      = (1 << 1)
} NS_ENUM_AVAILABLE_IOS(7_0);

<a>

// This defines the currently supported value for NSTextEffectAttributeName as of iOS 7.0

UIKIT_EXTERN NSString *const NSTextEffectLetterpressStyle NS_AVAILABLE_IOS(7_0);

<a>

/************** Attribute fixing ************/

@interface NSMutableAttributedString (NSMutableAttributedStringKitAdditions)

// This method fixes attribute inconsistencies inside range. It ensures NSFontAttributeName covers the characters, NSParagraphStyleAttributeName is only changing at paragraph boundaries, and NSTextAttachmentAttributeName is assigned to NSTextAttachmentCharacter. NSTextStorage automatically invokes this method via -ensureAttributesAreFixedInRange:.
- (void)fixAttributesInRange:(NSRange)range NS_AVAILABLE_IOS(7_0);

@end

<a>

/************************ Document formats ************************/

// Supported document types for the NSDocumentTypeDocumentAttribute key in the document attributes dictionary.

UIKIT_EXTERN NSString *const NSPlainTextDocumentType NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const NSRTFTextDocumentType NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const NSRTFDTextDocumentType NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const NSHTMLTextDocumentType NS_AVAILABLE_IOS(7_0);
// Keys for NSLayoutOrientationSectionsAttribute.
UIKIT_EXTERN NSString *const NSTextLayoutSectionOrientation NS_AVAILABLE_IOS(7_0); // NSNumber containing NSTextLayoutOrientation value. default: NSTextLayoutOrientationHorizontal
UIKIT_EXTERN NSString *const NSTextLayoutSectionRange NS_AVAILABLE_IOS(7_0); // NSValue containing NSRange representing a character range. default: a range covering the whole document
// Keys for options and document attributes dictionaries.  They are in and out document properties used by both read/write methods.
UIKIT_EXTERN NSString *const NSDocumentTypeDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"DocumentType", one of the document types declared above.  For reader methods, this key in options can specify the document type for interpreting the contents.  Upon return, the document attributes can contain this key for indicating the actual format used to read the contents.  For write methods, this key specifies the format for generating the data.
// NSPlainTextDocumentType document attributes
UIKIT_EXTERN NSString *const NSCharacterEncodingDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"CharacterEncoding", NSNumber containing integer specifying NSStringEncoding for the file; default for plain text is the default encoding.  This key in options can specify the string encoding for reading the data.  Upon return, the document attributes can contain the actual encoding used.  For writing methods, this value is used for generating the plain text data.
UIKIT_EXTERN NSString *const NSDefaultAttributesDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"DefaultAttributes", NSDictionary containing attributes to be applied to plain files.  Used by reader methods.  This key in options can specify the default attributes applied to the entire document contents.  The document attributes can contain this key indicating the actual attributes used.
// NSRTFTextDocumentType and NSRTFDTextDocumentType document attributes

// Document dimension

// They are document attributes used by read/write methods.
UIKIT_EXTERN NSString *const NSPaperSizeDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"PaperSize", NSValue containing CGSize (in points)
UIKIT_EXTERN NSString *const NSPaperMarginDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"PaperMargin", NSValue containing UIEdgeInsets
UIKIT_EXTERN NSString *const NSViewSizeDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"ViewSize", NSValue containing CGSize (in points)
UIKIT_EXTERN NSString *const NSViewZoomDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"ViewZoom", NSNumber containing floating point value (100 == 100% zoom)
UIKIT_EXTERN NSString *const NSViewModeDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"ViewMode", NSNumber containing integer; 0 = normal; 1 = page layout

// Document settings

 // They are document attributes used by read/write methods.
UIKIT_EXTERN NSString *const NSReadOnlyDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"ReadOnly", NSNumber containing integer; if missing, or 0 or negative, not readonly; 1 or more, readonly. Note that this has nothing to do with the file system protection on the file, but instead, on how the file should be displayed to the user
UIKIT_EXTERN NSString *const NSBackgroundColorDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"BackgroundColor", UIColor, representing the document-wide page background color
UIKIT_EXTERN NSString *const NSHyphenationFactorDocumentAttribute NS_AVAILABLE_IOS(7_0);  // @"HyphenationFactor", NSNumber containing floating point value (0=off, 1=full hyphenation)
UIKIT_EXTERN NSString *const NSDefaultTabIntervalDocumentAttribute     NS_AVAILABLE_IOS(7_0);  // @"DefaultTabInterval", NSNumber containing floating point value, representing the document-wide default tab stop interval, in points
UIKIT_EXTERN NSString *const NSTextLayoutSectionsAttribute NS_AVAILABLE_IOS(7_0);  // NSArray of dictionaries.  Each dictionary describing a layout orientation section.  The dictionary can have two attributes: NSTextLayoutSectionOrientation and NSTextLayoutSectionRange.  When there is a gap between sections, it's assumed to have NSTextLayoutOrientationHorizontal.


@interface NSAttributedString (NSAttributedStringDocumentFormats)

// Methods initializing the receiver contents with an external document data. options specify document attributes for interpreting the document contents. NSDocumentTypeDocumentAttribute, NSCharacterEncodingDocumentAttribute, and NSDefaultAttributesDocumentAttribute are supported options key. When they are not specified, these methods will examine the data and do their best to detect the appropriate attributes. If dict is non-NULL, it will return a dictionary with various document-wide attributes accessible via NS...DocumentAttribute keys.
- (instancetype)initWithFileURL:(NSURL *)url options:(NSDictionary *)options documentAttributes:(NSDictionary **)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);
- (instancetype)initWithData:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary **)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);

// Generates an NSData object for the receiver contents in range. It requires a document attributes dict specifying at least the NSDocumentTypeDocumentAttribute to determine the format to be written.
- (NSData *)dataFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);
</a>

// Returns an NSFileWrapper object for the receiver contents in range. It requires a document attributes dict specifying at least the NSDocumentTypeDocumentAttribute to determine the format to be written. The method returns a directory file wrapper for those document types represented by a file package such as NSRTFDTextDocumentType; otherwise, it returns a regular-file file wrapper.
- (NSFileWrapper *)fileWrapperFromRange:(NSRange)range documentAttributes:(NSDictionary *)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);
@end
</a>

@interface NSMutableAttributedString (NSMutableAttributedStringDocumentFormats)

Methods replacing the receiver contents with an external document data. options specify document attributes for interpreting the document contents. NSDocumentTypeDocumentAttribute, NSCharacterEncodingDocumentAttribute, and NSDefaultAttributesDocumentAttribute are supported options key. When they are not specified, these methods will examine the data and do their best to detect the appropriate attributes. If dict is non-NULL, it will return a dictionary with various document-wide attributes accessible via NS...DocumentAttribute keys.

<a>
- (BOOL)readFromFileURL:(NSURL *)url options:(NSDictionary *)opts documentAttributes:(NSDictionary **)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);
- (BOOL)readFromData:(NSData *)data options:(NSDictionary *)opts documentAttributes:(NSDictionary **)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市续徽,隨后出現(xiàn)的幾起案子张足,更是在濱河造成了極大的恐慌灯抛,老刑警劉巖洪添,帶你破解...
    沈念sama閱讀 218,755評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件拥褂,死亡現(xiàn)場離奇詭異赁咙,居然都是意外死亡镇匀,警方通過查閱死者的電腦和手機(jī)照藻,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來汗侵,“玉大人幸缕,你說我怎么就攤上這事∥希” “怎么了发乔?”我有些...
    開封第一講書人閱讀 165,138評(píng)論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長雪猪。 經(jīng)常有香客問我栏尚,道長,這世上最難降的妖魔是什么只恨? 我笑而不...
    開封第一講書人閱讀 58,791評(píng)論 1 295
  • 正文 為了忘掉前任译仗,我火速辦了婚禮,結(jié)果婚禮上坤次,老公的妹妹穿的比我還像新娘。我一直安慰自己斥赋,他們只是感情好缰猴,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,794評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著疤剑,像睡著了一般滑绒。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上隘膘,一...
    開封第一講書人閱讀 51,631評(píng)論 1 305
  • 那天疑故,我揣著相機(jī)與錄音,去河邊找鬼弯菊。 笑死纵势,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播钦铁,決...
    沈念sama閱讀 40,362評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼软舌,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了牛曹?” 一聲冷哼從身側(cè)響起佛点,我...
    開封第一講書人閱讀 39,264評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎黎比,沒想到半個(gè)月后超营,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,724評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡阅虫,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,900評(píng)論 3 336
  • 正文 我和宋清朗相戀三年演闭,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片书妻。...
    茶點(diǎn)故事閱讀 40,040評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡船响,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出躲履,到底是詐尸還是另有隱情见间,我是刑警寧澤,帶...
    沈念sama閱讀 35,742評(píng)論 5 346
  • 正文 年R本政府宣布工猜,位于F島的核電站米诉,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏篷帅。R本人自食惡果不足惜史侣,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,364評(píng)論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望魏身。 院中可真熱鬧惊橱,春花似錦、人聲如沸箭昵。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽家制。三九已至正林,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間颤殴,已是汗流浹背觅廓。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評(píng)論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留涵但,地道東北人杈绸。 一個(gè)月前我還...
    沈念sama閱讀 48,247評(píng)論 3 371
  • 正文 我出身青樓帖蔓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親蝇棉。 傳聞我的和親對(duì)象是個(gè)殘疾皇子讨阻,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,979評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容