Contents

attachmentBounds(for:proposedLineFragment:glyphPosition:characterIndex:)

Returns the layout bounds of the text attachment to the layout manager.

Declaration

func attachmentBounds(for textContainer: NSTextContainer?, proposedLineFragment lineFrag: CGRect, glyphPosition position: CGPoint, characterIndex charIndex: Int) -> CGRect

Parameters

  • textContainer:

    The text container for the text being laid out.

  • lineFrag:

    The line fragment containing the text attachment.

  • position:

    The glyph location inside lineFrag which is the origin of the returned bounds rectangle.

  • charIndex:

    The character location inside the text storage for the attachment character.

Return Value

The bounds rectangle of the text attachment if not CGRectZero; otherwise, the rectangle of the size property of the attachment’s image property.

Discussion

Conforming objects can implement more sophisticated logic for negotiating the attachment bounds based on the available container space and proposed line fragment rectangle.