Instance Method


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


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



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


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


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


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.


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


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


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


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.