Mac Developer Library

Developer

AppKit Framework Reference NSTextBlock Class Reference

Options
Deployment Target:

On This Page
Language:

NSTextBlock

NSTextBlock objects represent a block of text laid out in a subregion of the text container. Text blocks appear as attributes on paragraphs, as part of the paragraph style.

The most important subclass is NSTextTableBlock, which represents a block of text that appears as a cell in a table. The table itself is represented by a separate class, NSTextTable, which is referenced by all of its NSTextTableBlock objects and which controls their sizing and positioning.

Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.4 and later.
  • Initializes and returns an empty text block object.

    Declaration

    Swift

    init()

    Objective-C

    - (instancetype)init

    Return Value

    An initialized text block object.

    Discussion

    This is the designated initializer for NSTextBlock.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Sets the background color of the text block.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor?

    Objective-C

    @property(copy) NSColor *backgroundColor

    Parameters

    color

    The new background color.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the background color of the text block.

    Declaration

    Swift

    @NSCopying var backgroundColor: NSColor?

    Objective-C

    @property(copy) NSColor *backgroundColor

    Return Value

    The background color of the text block.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Sets the border color of the specified edge of the text block.

    Declaration

    Swift

    func setBorderColor(_ color: NSColor?, forEdge edge: NSRectEdge)

    Objective-C

    - (void)setBorderColor:(NSColor *)color forEdge:(NSRectEdge)edge

    Parameters

    color

    The new color.

    edge

    The edge whose color is to be set.

    Discussion

    This setting has no visible effect unless the border width is larger than the default, which is 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Sets the color of all borders of the text block.

    Declaration

    Swift

    func setBorderColor(_ color: NSColor?)

    Objective-C

    - (void)setBorderColor:(NSColor *)color

    Parameters

    color

    The new color.

    Discussion

    This setting has no visible effect unless the border width is larger than the default, which is 0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the border color of the specified text block edge.

    Declaration

    Swift

    func borderColorForEdge(_ edge: NSRectEdge) -> NSColor?

    Objective-C

    - (NSColor *)borderColorForEdge:(NSRectEdge)edge

    Parameters

    edge

    The edge of the text block in question.

    Return Value

    The border color of the text block edge edge.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The following constants specify values used by the methods setValue:type:forDimension: and valueTypeForDimension:

    Declaration

    Swift

    enum NSTextBlockValueType : UInt { case AbsoluteValueType case PercentageValueType }

    Objective-C

    enum { NSTextBlockAbsoluteValueType = 0, NSTextBlockPercentageValueType = 1 }; typedef NSUInteger NSTextBlockValueType;

    Constants

    • AbsoluteValueType

      NSTextBlockAbsoluteValueType

      Absolute value in points.

      Available in OS X v10.4 and later.

    • PercentageValueType

      NSTextBlockPercentageValueType

      Percentage value (out of 100).

      Available in OS X v10.4 and later.

    • NSTextBlockValueType

      NSTextBlockValueType

      A type defined for the text block value type constants.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The following constants specify values used by the methods setValue:type:forDimension:, valueForDimension:, and valueTypeForDimension:.

    Declaration

    Swift

    enum NSTextBlockDimension : UInt { case Width case MinimumWidth case MaximumWidth case Height case MinimumHeight case MaximumHeight }

    Objective-C

    enum { NSTextBlockWidth = 0, NSTextBlockMinimumWidth = 1, NSTextBlockMaximumWidth = 2, NSTextBlockHeight = 4, NSTextBlockMinimumHeight = 5, NSTextBlockMaximumHeight = 6 }; typedef NSUInteger NSTextBlockDimension;

    Constants

    • Width

      NSTextBlockWidth

      Width of the text block.

      Available in OS X v10.4 and later.

    • MinimumWidth

      NSTextBlockMinimumWidth

      Minimum width of the text block.

      Available in OS X v10.4 and later.

    • MaximumWidth

      NSTextBlockMaximumWidth

      Maximum width of the text block.

      Available in OS X v10.4 and later.

    • Height

      NSTextBlockHeight

      Height of the text block.

      Available in OS X v10.4 and later.

    • MinimumHeight

      NSTextBlockMinimumHeight

      Minimum height of the text block.

      Available in OS X v10.4 and later.

    • MaximumHeight

      NSTextBlockMaximumHeight

      Maximum height of the text block.

      Available in OS X v10.4 and later.

    • NSTextBlockDimension

      NSTextBlockDimension

      A type defined for the text block dimension constants.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Declaration

    Swift

    enum NSTextBlockLayer : Int { case Padding case Border case Margin }

    Objective-C

    enum { NSTextBlockPadding = -1, NSTextBlockBorder = 0, NSTextBlockMargin = 1 }; typedef NSInteger NSTextBlockLayer;

    Constants

    • Padding

      NSTextBlockPadding

      Padding of the text block: space surrounding the content area extending to the border.

      Available in OS X v10.4 and later.

    • Border

      NSTextBlockBorder

      Border of the text block: space between padding and margin, typically colored to present a visible boundary.

      Available in OS X v10.4 and later.

    • Margin

      NSTextBlockMargin

      Margin of the text block: space surrounding the border.

      Available in OS X v10.4 and later.

    • NSTextBlockLayer

      NSTextBlockLayer

      A type defined for the text block layer constants.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The following constants specify values used by the methods setVerticalAlignment: and verticalAlignment.

    Declaration

    Swift

    enum NSTextBlockVerticalAlignment : UInt { case TopAlignment case MiddleAlignment case BottomAlignment case BaselineAlignment }

    Objective-C

    enum { NSTextBlockTopAlignment = 0, NSTextBlockMiddleAlignment = 1, NSTextBlockBottomAlignment = 2, NSTextBlockBaselineAlignment = 3 }; typedef NSUInteger NSTextBlockVerticalAlignment;

    Constants

    • TopAlignment

      NSTextBlockTopAlignment

      Aligns adjacent blocks at their top.

      Available in OS X v10.4 and later.

    • MiddleAlignment

      NSTextBlockMiddleAlignment

      Aligns adjacent blocks at their middle.

      Available in OS X v10.4 and later.

    • BottomAlignment

      NSTextBlockBottomAlignment

      Aligns adjacent blocks at their bottom.

      Available in OS X v10.4 and later.

    • BaselineAlignment

      NSTextBlockBaselineAlignment

      Aligns adjacent blocks at the baseline of the first line of text in the block.

      Available in OS X v10.4 and later.

    • NSTextBlockVerticalAlignment

      NSTextBlockVerticalAlignment

      A type defined for the text block vertical alignment constants.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.