Instance Method

lineFragmentRectForProposedRect:atIndex:writingDirection:remainingRect:

Returns the bounds of a line fragment rectangle inside the receiver for the proposed rectangle.

Declaration

iOS, tvOS
- (CGRect)lineFragmentRectForProposedRect:(CGRect)proposedRect atIndex:(NSUInteger)characterIndex writingDirection:(NSWritingDirection)baseWritingDirection remainingRect:(CGRect *)remainingRect;
macOS
- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect atIndex:(NSUInteger)characterIndex writingDirection:(NSWritingDirection)baseWritingDirection remainingRect:(NSRect *)remainingRect;

Parameters

proposedRect

A rectangle in which to lay out text proposed by the layout manager.

characterIndex

The character location inside the text storage for the line fragment being processed.

baseWritingDirection

The direction of advancement for line fragments inside a visual horizontal line. The values passed into the method are either NSWritingDirectionLeftToRight or NSWritingDirectionRightToLeft.

remainingRect

The remainder of the proposed rectangle that was excluded from returned rectangle. It can be passed in as the proposed rectangle for the next iteration.

Discussion

The bounds of the line fragment rectangle are determined by the intersection of proposedRect and the text container’s bounding rectangle defined by its NSTextContainer property. The regions defined by the NSTextContainer property are excluded from the return value. It is possible that proposedRect can be divided into multiple line fragments due to exclusion paths. In that case, remainingRect returns the remainder that can be passed in as the proposed rectangle for the next iteration.

This method can be overridden by subclasses for further text container region customization.

See Also

Constraining Text Layout

maximumNumberOfLines

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

lineFragmentPadding

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

simpleRectangularTextContainer

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.