attachmentBounds(for:location:textContainer:proposedLineFragment:position:)
Returns the layout bounds of the attachment you specify.
Declaration
func attachmentBounds(for attributes: [NSAttributedString.Key : Any], location: any NSTextLocation, textContainer: NSTextContainer?, proposedLineFragment: CGRect, position: CGPoint) -> CGRectParameters
- attributes:
A dictionary of Key attributes.
- location:
An Nstextlocation that indicates that start of the string.
- textContainer:
The Nstextcontainer that contains the source text.
- proposedLineFragment:
A Cgrect that describes the boundaries of the line fragment.
- position:
A Cgpoint inside
proposedLineFragment.
Return Value
Returns a CGRect that describes the boundaries of the attachment, or CGRectZero.
Discussion
The framework interprets the bounds origin to match position inside proposedLineFragment. The default NSTextAttachment implementation returns bounds if the value isn’t equivalent to CGRectZero; otherwise, it derives the bounds value from image.size. Conforming objects can implement more sophisticated logic for negotiating the frame size based on the available container space and proposed line fragment rectangle.