Creates a truncated line from an existing line.


func CTLineCreateTruncatedLine(_ line: CTLine, _ width: Double, _ truncationType: CTLineTruncationType, _ truncationToken: CTLine?) -> CTLine?



The line from which to create a truncated line.


The width at which truncation begins. The line is truncated if its width is greater than the width passed in this parameter.


The type of truncation to perform if needed. See CTLineTruncationType for possible values.


This token is added at the point where truncation took place, to indicate that the line was truncated. Usually, the truncation token is the ellipsis character (U+2026). If this parameter is set to NULL, then no truncation token is used and the line is simply cut off.

Return Value

A reference to a truncated CTLine object if the call was successful; otherwise, NULL.


The line specified in truncationToken should have a width less than the width specified by the width parameter. If the width of the line specified in truncationToken is greater than width and truncation is needed, the function returns NULL.

See Also

Creating Lines

func CTLineCreateWithAttributedString(CFAttributedString) -> CTLine

Creates a single immutable line object directly from an attributed string.

func CTLineCreateJustifiedLine(CTLine, CGFloat, Double) -> CTLine?

Creates a justified line from an existing line.