NSAttributedString record, nsattributedstring

Source: Internet
Author: User

NSAttributedString record, nsattributedstring

/// NSAttributedString. h // UIKit // Copyright (c) 2011-2014 Apple Inc. all rights reserved. // # import <Foundation/Foundation. h> # import <UIKit/UIKitDefines. h>/************************ Attributes ************ * ********** // * Predefined character attributes for text. if the key is not in the dictionary, then use the default values as described below. * pre-defined text character attributes. If the key is not in the specified Dictionary, the following describes the attributes. * // Font UIKIT_EXTERN NSString * const NSFontAttributeName limit (6_0); // UIFont, default Helvetica (Neue) 12 // section style UIKIT_EXTERN NSString * const limit (6_0 ); // NSParagraphStyle, default defaultParagraphStyle // text color UIKIT_EXTERN NSString * const NSForegroundColorAttributeName NS_AVAILABLE_IOS (6_0); // UIColor, default blackColor // text background color UIKIT_EXTERN NSString * const NSBackgroundColorAttributeName NS_AVAILABLE_IOS (6_0); // UIColor, default nil: no background // you can specify the value as an integer of the NSNumber object ), 0 indicates no conjoined characters. 1 indicates that the default conjoined character UIKIT_EXTERN NSString * const NSLigatureAttributeName NS_AVAILABLE_IOS (6_0); // NSNumber containing integer, default 1: default ligatures, 0: no ligatures // set the Character Spacing 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. // set the strikethrough line UIKIT_EXTERN NSString * const limit NS_AVAILABLE_IOS (6_0); // NSNumber containing integer, default 0: no strikethrough // underline UIKIT_EXTERN NSString * const limit (6_0 ); // NSNumber containing integer, default 0: no underline // fill part color same as foreground colorUIKIT_EXTERN NSString * const NSStrokeColorAttributeName NS_AVAILABLE_IOS (6_0); // UIColor, default nil: same as foreground color // set the stroke width UIKIT_EXTERN NSString * const limit 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 wocould be 3.0) // shadow attribute UIKIT_EXTERN NSString * const NSShadowAttributeName values (6_0); // NSShadow, default nil: no shadow // special text effect UIKIT_EXTERN NSString * const incluns_available_ios (7_0); // NSString, default nil: no text effect // text attachment; Value: NSTextAttachment object, it is often used in text image mixing UIKIT_EXTERN NSString * const NSAttachmentAttributeName NS_AVAILABLE_IOS (7_0); // NSTextAttachment, default nil // sets the link property, call the browser to open the specified URL UIKIT_EXTERN NSString * const NSLinkAttributeName NS_AVAILABLE_IOS (7_0); // NSURL (preferred) or your NSString * const limit NS_AVAILABLE_IOS (7_0 ); // NSNumber containing floating point value, in points; offset from baseline, default 0 // you can specify the baseline offset value as NSNumber (float, negative values are UIKIT_EXTERN NSString * const NSUnderlineColorAttributeName NS_AVAILABLE_IOS (7_0); // UIColor, default nil: same as foreground color // you can specify the strikethrough color. The value is a UIColor object, the default value is black UIKIT_EXTERN NSString * const incluns_available_ios (7_0); // UIColor, default nil: same as foreground color // sets the font skew. The value is NSNumber (float), and the positive value is right tilt, negative value: UIKIT_EXTERN NSString * const limit NS_AVAILABLE_IOS (7_0); // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew // you can specify the property of text horizontal stretching, the value is NSNumber (float), positive value: horizontal text stretching, negative value: horizontal compression text 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 // set the text writing direction, UIKIT_EXTERN NSString * const limit 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: Direction | direction, RLE: nswritingdirerighttoleft | direction, LRO: Direction | direction, RLO: nswritingdirerighttoleft | direction, // set the text layout direction to the NSNumber object (integer ), 0 indicates horizontal text, 1 indicates vertical text 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 cocould follow higher-level vertical orientation settings. currently on iOS, it's always horizontal. the behavior for any other value is undefined. /* This defines currently supported values for NSUnderlineStyleAttributeName and NSStrikethroughStyleAttributeName. * The style supported by underline and strikethrough is defined below */typedef NS_ENUM (NSInteger, NSUnderlineStyle) {NSUnderlineStyleNone = 0x00, // do not set the underline NSUnderlineStyleSingle = 0x01, // set the strikethrough line to the line NSUnderlineStyleThick NS_ENUM_AVAILABLE_IOS (7_0) = 0x02, // set the strikethrough line to the line NSUnderlineStyleDouble limit (7_0) = 0x09, // set strikethrough to fine dual solid line // http://blog.csdn.net/harvic880925/article/details/9028823 reference NSUnderlinePatternSolid limit (7_0) = 0x0000, // solid line NSUnderlinePatternDot NS_ENUM_AVAILABLE_IOS (7_0) = 0x0100, // NSUnderlinePatternDash threshold (7_0) = 0x0200, // The dotted NSUnderlinePatternDashDot threshold (7_0) = 0x0300, then NS_ENUM_AVAILABLE_IOS (7_0) = 0x0400, NSUnderlineByWord NS_ENUM_AVAILABLE_IOS (7_0) = 0x8000} NS_ENUM_AVAILABLE_IOS (6_0);/* NSTextWritingDirection values used by nswritingdireattributename. can specify the formatting controls defined by Unicode Bidirectional Algorithm. */typedef NS_ENUM (NSInteger, NSTextWritingDirection) {nstextwritingdireembedding = (0 <1), latency = (1 <1)} NS_ENUM_AVAILABLE_IOS (7_0 ); /* This defines the currently supported value for NSTextEffectAttributeName as of iOS 7.0 */UIKIT_EXTERN NSString * const NSTextEffectLetterpressStyle NS_AVAILABLE_IOS (7_0 ); /*********************** 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 :( nsange) range NS_AVAILABLE_IOS (7_0 ); @ end/************************ Document formats *********** * *********** // Supported document types for the NSDocumentTypeDocumentAttribute key in the document attributes dictionary. required NSString * const limit (7_0); // common text UIKIT_EXTERN NSString * const NSRTFTextDocumentType limit (7_0); UIKIT_EXTERN NSString * const NSRTFDTextDocumentType limit (7_0 ); UIKIT_EXTERN NSString * const NSHTMLTextDocumentType NS_AVAILABLE_IOS (7_0); // HTML // Keys for nslayoutorientationsectionsattriys. // UIKIT_EXTERN NSString * const NSTextLayoutSectionOrientation NS_AVAILABLE_IOS (7_0); // NSNumber containing NSTextLayoutOrientation value. default: bytes // The character range UIKIT_EXTERN NSString * const NSTextLayoutSectionRange NS_AVAILABLE_IOS (7_0); // NSValue containing nsange 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 in 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 encode (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 limit (7_0); // @ "PaperSize", NSValue containing CGSize (in points) UIKIT_EXTERN NSString * const limit NS_AVAILABLE_IOS (7_0 ); // @ "PaperMargin", NSValue containing required NSString * const NSViewSizeDocumentAttribute NS_AVAILABLE_IOS (7_0); // @ "ViewSize", NSValue containing CGSize (in points) UIKIT_EXTERN NSString * const limit (7_0); // @ "ViewZoom", NSNumber containing floating point value (100 = 100% zoom) UIKIT_EXTERN NSString * const NSViewModeDocumentAttribute limit (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 shocould be displayed to the userUIKIT_EXTERN NSString * const NSBackgroundColorDocumentAttribute NS_AVAILABLE_IOS (7_0 ); // @ "BackgroundColor", UIColor, representing the document-wide page background colorUIKIT_EXTERN NSString * const NSHyphenationFactorDocumentAttribute NS_AVAILABLE_IOS (7_0); // @ "HyphenationFactor ", NSNumber containing floating point value (0 = off, 1 = full hyphenation) UIKIT_EXTERN NSString * const limit NS_AVAILABLE_IOS (7_0); // @ "DefaultTabInterval", NSNumber containing floating point value, representing the document-wide default tab stop interval, in pointsUIKIT_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 specified Er contents with an external document data. options specify document attributes for interpreting the document contents. NSDocumentTypeDocumentAttribute, NSCharacterEncodingDocumentAttribute, and NSDefaultAttributesDocumentAttribute are ororted 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 failed (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 specified Er contents in range. it requires a document attributes dict specifying at least the NSDocumentTypeDocumentAttribute to determine the format to be written. -(NSData *) dataFromRange :( nsange) range documentAttributes :( NSDictionary *) dict error :( NSError **) error NS_AVAILABLE_IOS (7_0 ); // Returns an NSFileWrapper object for the specified Er 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 wrapper. -(NSFileWrapper *) fileWrapperFromRange :( nsange) range documentAttributes :( NSDictionary *) dict error :( NSError **) error NS_AVAILABLE_IOS (7_0); @ end @ interface failed (response) // Methods replacing the specified Er contents with an external document data. options specify document attributes for interpreting the document contents. NSDocumentTypeDocumentAttribute, NSCharacterEncodingDocumentAttribute, and NSDefaultAttributesDocumentAttribute are ororted 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. -(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); @ end

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.