lineFragmentRect(forProposedRect:at:writingDirection:remaining:)
Returns the bounds of a line fragment rectangle inside the text container for the proposed rectangle.
Declaration
func lineFragmentRect(forProposedRect proposedRect: CGRect, at characterIndex: Int, writingDirection baseWritingDirection: NSWritingDirection, remaining remainingRect: UnsafeMutablePointer<CGRect>?) -> CGRectParameters
- 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 Lefttoright or Righttoleft.
- 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.