Class

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.

Overview

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.

Symbols

Creating text blocks

init()

Initializes and returns an empty text block object.

Working with dimensions of content

func value(for: NSTextBlockDimension)

Returns the value of the specified text block dimension.

func valueType(for: NSTextBlockDimension)

Returns the value type of the specified text block dimension.

var contentWidth: CGFloat

The width of the text block.

var contentWidthValueType: NSTextBlockValueType

The type of value stored for the text block width.

Getting and setting margins, borders, and padding

func setWidth(CGFloat, type: NSTextBlockValueType, for: NSTextBlockLayer, edge: NSRectEdge)

Sets the width of a specified edge of a specified layer of the text block.

func setWidth(CGFloat, type: NSTextBlockValueType, for: NSTextBlockLayer)

Sets the width of all edges of a specified layer of the text block.

func width(for: NSTextBlockLayer, edge: NSRectEdge)

Returns the width of an edge of a specified layer of the text block.

func widthValueType(for: NSTextBlockLayer, edge: NSRectEdge)

Returns the value type of an edge of a specified layer of the text block.

Getting and setting alignment

var verticalAlignment: NSTextBlockVerticalAlignment

The vertical alignment of the text block.

Working with color

var backgroundColor: NSColor?

The background color of the text block.

func setBorderColor(NSColor?, for: NSRectEdge)

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

func setBorderColor(NSColor?)

Sets the color of all borders of the text block.

func borderColor(for: NSRectEdge)

Returns the border color of the specified text block edge.

Determining size and position of a text block

func rectForLayout(at: NSPoint, in: NSRect, textContainer: NSTextContainer, characterRange: NSRange)

Returns the rectangle within which glyphs should be laid out for the specified arguments.

func boundsRect(forContentRect: NSRect, in: NSRect, textContainer: NSTextContainer, characterRange: NSRange)

Returns the rectangle the text in the block actually occupies, including padding, borders, and margins.

Drawing colors and decorations

func drawBackground(withFrame: NSRect, in: NSView, characterRange: NSRange, layoutManager: NSLayoutManager)

Called by the layout manager to draw any colors and other decorations before the text is drawn.

Constants

NSTextBlockValueType

The following constants specify values used by the methods setValue(_:type:for:) and valueType(for:) to specify text block value types.

NSTextBlockDimension

The following constants specify values used by the methods setValue(_:type:for:), value(for:), and valueType(for:) to specify text block dimensions.

NSTextBlockLayer

The following constants specify values used by the properties and methods contentWidthValueType, setWidth(_:type:for:edge:), setWidth(_:type:for:), width(for:edge:), and widthValueType(for:edge:) to specify text block layer values.

NSTextBlockVerticalAlignment

The following constants specify values used by the property verticalAlignment to specify vertical alignment.

Instance Methods

Relationships

Inherits From