Mac Developer Library

Developer

AppKit Framework Reference NSParagraphStyle Class Reference

Options
Deployment Target:

On This Page
Language:

NSParagraphStyle

The NSParagraphStyle class and its subclass NSMutableParagraphStyle encapsulate the paragraph or ruler attributes used by the NSAttributedString classes. Instances of these classes are often referred to as paragraph style objects or, when no confusion will result, paragraph styles.

The mutable subclass of NSParagraphStyle is NSMutableParagraphStyle.

  • Returns the default paragraph style.

    Declaration

    Swift

    class func defaultParagraphStyle() -> NSParagraphStyle

    Objective-C

    + (NSParagraphStyle *)defaultParagraphStyle

    Discussion

    The default paragraph style has the following default values:

    Subattribute

    Default Value

    Alignment

    NSNaturalTextAlignment

    Tab stops (Mac OS X only)

    12 left-aligned tabs, spaced by 28.0 points

    Line break mode

    NSLineBreakByWordWrapping

    All others

    0.0

    See individual method descriptions for explanations of each subattribute.

    Availability

    Available in OS X v10.0 and later.

  • An array specifying the text blocks containing the paragraph. (read-only)

    Declaration

    Swift

    var textBlocks: [NSTextBlock] { get }

    Objective-C

    @property(readonly, copy) NSArray <__kindof NSTextBlock *> *textBlocks

    Availability

    Available in OS X v10.4 and later.

  • An array specifying the text lists containing the paragraph. (read-only)

    Declaration

    Swift

    var textLists: [NSTextList] { get }

    Objective-C

    @property(readonly, copy) NSArray <NSTextList *> *textLists

    Availability

    Available in OS X v10.4 and later.

  • The threshold for using tightening as an alternative to truncation. (read-only)

    Declaration

    Swift

    var tighteningFactorForTruncation: Float { get }

    Objective-C

    @property(readonly) float tighteningFactorForTruncation

    Discussion

    When the line break mode specifies truncation, the text system attempts to tighten inter character spacing as an alternative to truncation, provided that the ratio of the text width to the line fragment width does not exceed 1.0 + the tightening factor is set to this property. Otherwise the text is truncated at a location determined by the line break mode.

    Availability

    Available in OS X v10.4 and later.

  • A boolean that specifies whether the paragraph is to be treated as a header for purposes of HTML generation. (read-only)

    Declaration

    Swift

    var headerLevel: Int { get }

    Objective-C

    @property(readonly) NSInteger headerLevel

    Discussion

    The value is 0 (the default value), if the paragraph is not a header, or from 1 through 6 if the paragraph is to be treated as a header.

    Availability

    Available in OS X v10.4 and later.

  • These constants specify what happens when a line is too long for its container.

    Declaration

    Swift

    enum NSLineBreakMode : UInt { case ByWordWrapping case ByCharWrapping case ByClipping case ByTruncatingHead case ByTruncatingTail case ByTruncatingMiddle }

    Objective-C

    enum { NSLineBreakByWordWrapping = 0, NSLineBreakByCharWrapping, NSLineBreakByClipping, NSLineBreakByTruncatingHead, NSLineBreakByTruncatingTail, NSLineBreakByTruncatingMiddle }; typedef NSUInteger NSLineBreakMode

    Constants

    • ByWordWrapping

      NSLineBreakByWordWrapping

      Wrapping occurs at word boundaries, unless the word itself doesn’t fit on a single line. See Characters and Grapheme Clusters in String Programming Guide for a discussion of issues related to determining word boundaries.

      Available in OS X v10.0 and later.

    • ByCharWrapping

      NSLineBreakByCharWrapping

      Wrapping occurs before the first character that doesn’t fit.

      Available in OS X v10.0 and later.

    • ByClipping

      NSLineBreakByClipping

      Lines are simply not drawn past the edge of the text container.

      Available in OS X v10.0 and later.

    • ByTruncatingHead

      NSLineBreakByTruncatingHead

      The line is displayed so that the end fits in the container and the missing text at the beginning of the line is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.

      Available in OS X v10.0 and later.

    • ByTruncatingTail

      NSLineBreakByTruncatingTail

      The line is displayed so that the beginning fits in the container and the missing text at the end of the line is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.

      Available in OS X v10.0 and later.

    • ByTruncatingMiddle

      NSLineBreakByTruncatingMiddle

      The line is displayed so that the beginning and end fit in the container and the missing text in the middle is indicated by an ellipsis glyph. Although this mode works for multiline text, it is more often used for single line text.

      Available in OS X v10.0 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.