系统关键字段
import Foundation
import UIKit
import _SwiftUIKitOverlayShims
extension NSAttributedStringKey {
/** Attributes **/
@available(iOS 6.0, *)
public static let font: NSAttributedStringKey
@available(iOS 6.0, *)
public static let paragraphStyle: NSAttributedStringKey // NSParagraphStyle, default defaultParagraphStyle
@available(iOS 6.0, *)
public static let foregroundColor: NSAttributedStringKey // UIColor, default blackColor
@available(iOS 6.0, *)
public static let backgroundColor: NSAttributedStringKey // UIColor, default nil: no background
@available(iOS 6.0, *)
public static let ligature: NSAttributedStringKey // NSNumber containing integer, default 1: default ligatures, 0: no ligatures
@available(iOS 6.0, *)
public static let kern: NSAttributedStringKey // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled.
@available(iOS 6.0, *)
public static let strikethroughStyle: NSAttributedStringKey // NSNumber containing integer, default 0: no strikethrough
@available(iOS 6.0, *)
public static let underlineStyle: NSAttributedStringKey // NSNumber containing integer, default 0: no underline
@available(iOS 6.0, *)
public static let strokeColor: NSAttributedStringKey // UIColor, default nil: same as foreground color
@available(iOS 6.0, *)
public static let strokeWidth: NSAttributedStringKey // 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)
@available(iOS 6.0, *)
public static let shadow: NSAttributedStringKey // NSShadow, default nil: no shadow
@available(iOS 7.0, *)
public static let textEffect: NSAttributedStringKey // NSString, default nil: no text effect
@available(iOS 7.0, *)
public static let attachment: NSAttributedStringKey // NSTextAttachment, default nil
@available(iOS 7.0, *)
public static let link: NSAttributedStringKey // NSURL (preferred) or NSString
@available(iOS 7.0, *)
public static let baselineOffset: NSAttributedStringKey // NSNumber containing floating point value, in points; offset from baseline, default 0
@available(iOS 7.0, *)
public static let underlineColor: NSAttributedStringKey // UIColor, default nil: same as foreground color
@available(iOS 7.0, *)
public static let strikethroughColor: NSAttributedStringKey // UIColor, default nil: same as foreground color
@available(iOS 7.0, *)
public static let obliqueness: NSAttributedStringKey // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew
@available(iOS 7.0, *)
public static let expansion: NSAttributedStringKey // NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion
@available(iOS 7.0, *)
public static let writingDirection: NSAttributedStringKey // 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,
@available(iOS 6.0, *)
public static let verticalGlyphForm: NSAttributedStringKey // 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.
}
// This defines currently supported values for NSUnderlineStyleAttributeName and NSStrikethroughStyleAttributeName. NSUnderlineStyle, NSUnderlinePattern, and NSUnderlineByWord are or’ed together to produce an underline style.
/** Attribute values **/
@available(iOS 6.0, *)
public enum NSUnderlineStyle : Int {
case styleNone
case styleSingle
@available(iOS 7.0, *)
case styleThick
@available(iOS 7.0, *)
case styleDouble
@available(iOS 7.0, *)
public static var patternSolid: NSUnderlineStyle { get }
@available(iOS 7.0, *)
case patternDot
@available(iOS 7.0, *)
case patternDash
@available(iOS 7.0, *)
case patternDashDot
@available(iOS 7.0, *)
case patternDashDotDot
@available(iOS 7.0, *)
case byWord
}
// NSWritingDirectionFormatType values used by NSWritingDirectionAttributeName. It is or’ed with either NSWritingDirectionLeftToRight or NSWritingDirectionRightToLeft. Can specify the formatting controls defined by Unicode Bidirectional Algorithm.
@available(iOS 9.0, *)
public enum NSWritingDirectionFormatType : Int {
case embedding
case override
}
extension NSAttributedString {
public struct TextEffectStyle : RawRepresentable, Equatable, Hashable {
public init(rawValue: String)
}
/** Attribute fixing **/
// 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 NSAttachmentCharacter. NSTextStorage automatically invokes this method via -ensureAttributesAreFixedInRange:.
/** Document formats **/
public struct DocumentType : RawRepresentable, Equatable, Hashable {
public init(_ rawValue: String)
public init(rawValue: String)
}
// Supported document types for the NSDocumentTypeDocumentAttribute key in the document attributes dictionary.
public struct TextLayoutSectionKey : RawRepresentable, Equatable, Hashable {
public init(rawValue: String)
}
// Keys for NSLayoutOrientationSectionsAttribute.
// NSNumber containing NSTextLayoutOrientation value. default: NSTextLayoutOrientationHorizontal
// NSValue containing NSRange representing a character range. default: a range covering the whole document
public struct DocumentAttributeKey : RawRepresentable, Equatable, Hashable {
public init(_ rawValue: String)
public init(rawValue: String)
}
// Keys for options and document attributes dictionaries. They are in and out document properties used by both read/write methods.
// @”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
// @”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.
// @”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.
// @”PaperSize”, NSValue containing CGSize (in points)
// @”PaperMargin”, NSValue containing UIEdgeInsets
// @”ViewSize”, NSValue containing CGSize (in points)
// @”ViewZoom”, NSNumber containing floating point value (100 == 100% zoom)
// @”ViewMode”, NSNumber containing integer; 0 = normal; 1 = page layout
// Document settings
// They are document attributes used by read/write methods.
// @”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
// @”BackgroundColor”, UIColor, representing the document-wide page background color
// @”HyphenationFactor”, NSNumber containing floating point value (0=off, 1=full hyphenation)
// @”DefaultTabInterval”, NSNumber containing floating point value, representing the document-wide default tab stop interval, in points
// 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.
public struct DocumentReadingOptionKey : RawRepresentable, Equatable, Hashable {
public init(_ rawValue: String)
public init(rawValue: String)
}
}
extension NSAttributedString.TextEffectStyle {
@available(iOS 7.0, *)
public static let letterpressStyle: NSAttributedString.TextEffectStyle
}
/** Attribute fixing **/
extension NSMutableAttributedString {
@available(iOS 7.0, *)
open func fixAttributes(in range: NSRange)
}
extension NSAttributedString.DocumentType {
@available(iOS 7.0, *)
public static let plain: NSAttributedString.DocumentType
@available(iOS 7.0, *)
public static let rtf: NSAttributedString.DocumentType
@available(iOS 7.0, *)
public static let rtfd: NSAttributedString.DocumentType
@available(iOS 7.0, *)
public static let html: NSAttributedString.DocumentType
}
extension NSAttributedString.TextLayoutSectionKey {
@available(iOS 7.0, *)
public static let orientation: NSAttributedString.TextLayoutSectionKey
@available(iOS 7.0, *)
public static let range: NSAttributedString.TextLayoutSectionKey
}
extension NSAttributedString.DocumentAttributeKey {
@available(iOS 7.0, *)
public static let documentType: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let characterEncoding: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let defaultAttributes: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let paperSize: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let paperMargin: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let viewSize: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let viewZoom: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let viewMode: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let readOnly: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let backgroundColor: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let hyphenationFactor: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let defaultTabInterval: NSAttributedString.DocumentAttributeKey
@available(iOS 7.0, *)
public static let textLayoutSections: NSAttributedString.DocumentAttributeKey
}
extension NSAttributedString.DocumentReadingOptionKey {
public static let documentType: NSAttributedString.DocumentReadingOptionKey
public static let defaultAttributes: NSAttributedString.DocumentReadingOptionKey // @”DefaultAttributes”, for plain text only; NSDictionary containing attributes to be applied to plain files
public static let characterEncoding: NSAttributedString.DocumentReadingOptionKey // @”CharacterEncoding”, for plain text and HTML; NSNumber containing integer specifying NSStringEncoding to be used to interpret the file
}
extension NSAttributedString {
// 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.
@available(iOS 9.0, *)
public init(url: URL, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer
@available(iOS 7.0, *)
public init(data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer
// 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.
@available(iOS 7.0, *)
open func data(from range: NSRange, documentAttributes dict: [NSAttributedString.DocumentAttributeKey : Any] = [:]) throws -> Data
// 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.
@available(iOS 7.0, *)
open func fileWrapper(from range: NSRange, documentAttributes dict: [NSAttributedString.DocumentAttributeKey : Any] = [:]) throws -> FileWrapper
}
extension NSMutableAttributedString {
// 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.
@available(iOS 9.0, *)
open func read(from url: URL, options opts: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer
@available(iOS 7.0, *)
open func read(from data: Data, options opts: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer
}
/** Misc methods **/
extension NSAttributedString {
// Returns YES if the receiver contains a property configured (NSAttachmentAttributeName with NSAttachmentCharacter) in range
@available(iOS 9.0, *)
open func containsAttachments(in range: NSRange) -> Bool
}
extension NSAttributedString : NSItemProviderReading, NSItemProviderWriting {
}
/** Deprecated **/
@available(iOS, introduced: 7.0, deprecated: 9.0, message: “Use NSWritingDirectionFormatType instead”)
public enum NSTextWritingDirection : Int {
case embedding
case override
}
extension NSAttributedString {
@available(iOS, introduced: 7.0, deprecated: 9.0, message: “Use -initWithURL:options:documentAttributes:error: instead”)
public init(fileURL url: URL, options: [AnyHashable : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer
}
extension NSMutableAttributedString {
@available(iOS, introduced: 7.0, deprecated: 9.0, message: “Use -readFromURL:options:documentAttributes:error: instead”)
open func read(fromFileURL url: URL, options opts: [AnyHashable : Any] = [:], documentAttributes dict: AutoreleasingUnsafeMutablePointer
}