Contents

image(for:attributes:location:textContainer:)

Returns the image object rendered at the bounds and inside the text container you specify.

Declaration

func image(for bounds: CGRect, attributes: [NSAttributedString.Key : Any] = [:], location: any NSTextLocation, textContainer: NSTextContainer?) -> NSImage?

Parameters

  • bounds:

    The Cgrect that presents the image boundaries inside textContainer.

  • attributes:

    A dictionary of Key attributes.

  • location:

    An Nstextlocation that indicates that start of the string.

  • textContainer:

    The Nstextcontainer that contains the source text.

Return Value

An optional image object.

Discussion

A custom implementation should return an image appropriate for the target rendering context that you derive by arguments to this method. The default NSTextAttachment implementation returns the contents of the image property when non-nil. If the image property is nil, it returns an image based on the contents and fileType properties.

See Also

Determining the characteristics of an attachment