Class

NSText​Container

The NSText​Container class defines a region where text is laid out. An NSLayout​Manager uses NSText​Container to determine where to break lines, lay out portions of text, and so on. An NSText​Container object normally defines rectangular regions, but you can define exclusion paths inside the text container to create regions where text does not flow. You can also subclass to create text containers with nonrectangular regions, such as circular regions, regions with holes in them, or regions that flow alongside graphics.

Overview

Instances of the NSText​Container, NSLayout​Manager, and NSText​Storage classes can be accessed from threads other than the main thread as long as the app guarantees access from only one thread at a time.

Symbols

Creating a Text Container

init(size:​ CGSize)

Initializes a text container with a specified bounding rectangle.

Managing Text Components

var layout​Manager:​ NSLayout​Manager?

The receiver’s layout manager.

func replace​Layout​Manager(NSLayout​Manager)

Replaces the layout manager for the group of text system objects containing the receiver.

var text​View:​ NSText​View?

The receiver’s text view.

Defining the Container Shape

var size:​ CGSize

The size of the text container’s bounding rectangle.

var exclusion​Paths:​ [UIBezier​Path]

An array of path objects representing the regions where text is not displayed in the text container.

var line​Break​Mode:​ NSLine​Break​Mode

The behavior of the last line inside the text container.

var container​Size:​ NSSize

The size of the receiver’s bounding rectangle.

Deprecated
var width​Tracks​Text​View:​ Bool

A Boolean that controls whether the receiver adjusts the width of its bounding rectangle when its text view is resized.

var height​Tracks​Text​View:​ Bool

A Boolean that controls whether the receiver adjusts the height of its bounding rectangle when its text view is resized.

Constraining Text Layout

var maximum​Number​Of​Lines:​ Int

The maximum number of lines that can be stored in the text container.

var line​Fragment​Padding:​ CGFloat

The amount by which text is inset within line fragment rectangles.

var is​Simple​Rectangular​Text​Container:​ Bool

A boolean that indicates whether the receiver’s region is a rectangle with no holes or gaps and whose edges are parallel to the text view's coordinate system axes.

Deprecated

init(container​Size:​ NSSize)

Initializes a text container with a specified bounding rectangle.

Deprecated
func line​Fragment​Rect(for​Proposed​Rect:​ NSRect, sweep​Direction:​ NSLine​Sweep​Direction, movement​Direction:​ NSLine​Movement​Direction, remaining:​ NSRect​Pointer?)

Overridden by subclasses to calculate and return the longest rectangle available in the proposed rectangle for displaying text, or NSZero​Rect if there is none according to the receiver’s region definition.

Deprecated
func contains(NSPoint)

Overridden by subclasses to return whether a point lies within the receiver’s region or on the region’s edge—not simply within its bounding rectangle.

Deprecated

Constants

NSLine​Sweep​Direction

These constants describe the progression of text on a page. The typesetter decides which way text is supposed to flow and passes these values as arguments to the text container, which uses them to calculate the next line rectangle.

NSLine​Movement​Direction

Line movement is the direction in which lines move. See Text System Storage Layer Overview.