Instance Method

layoutManager(_:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:in:forGlyphRange:)

Customizes the line fragment geometry before committing it to the layout cache.

Declaration

iOS, Mac Catalyst, tvOS
optional func layoutManager(_ layoutManager: NSLayoutManager, shouldSetLineFragmentRect lineFragmentRect: UnsafeMutablePointer<CGRect>, lineFragmentUsedRect: UnsafeMutablePointer<CGRect>, baselineOffset: UnsafeMutablePointer<CGFloat>, in textContainer: NSTextContainer, forGlyphRange glyphRange: NSRange) -> Bool
macOS
optional func layoutManager(_ layoutManager: NSLayoutManager, shouldSetLineFragmentRect lineFragmentRect: UnsafeMutablePointer<NSRect>, lineFragmentUsedRect: UnsafeMutablePointer<NSRect>, baselineOffset: UnsafeMutablePointer<CGFloat>, in textContainer: NSTextContainer, forGlyphRange glyphRange: NSRange) -> Bool

Parameters

layoutManager

The layout manager doing the work.

lineFragmentRect

The proposed rectangle that contains the glyphs. You may modify this rectangle as needed.

lineFragmentUsedRect

The portion of lineFragmentRect that actually contains glyphs or other rendered marks, including the text container's line fragment padding. This rectangle must be equal to lineFragmentRect or wholly contained by it. You may modify this rectangle as needed.

baselineOffset

The vertical distance (in pixels) from the line fragment origin to the baseline on which the glyphs align.

textContainer

The text container for the line fragments.

glyphRange

The range of glyphs being laid out.

Return Value

true if you modified the layout information and want your modifications to be used or false if the original layout information should be used.

Discussion

Use this method to modify the line fragment rectangles associated with the text container. It is your responsibility to ensure that the modified rectangles remain valid and still lie within the text container.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software