Instance Method


Returns the best representation of the image for the specified rectangle using the provided hints.


func bestRepresentation(for rect: NSRect, context referenceContext: NSGraphicsContext?, hints: [NSImageRep.HintKey : Any]?) -> NSImageRep?



The area of the image to return.


A graphics context. This value can be nil.


An optional dictionary of hints that provide more context for selecting or generating a CGImage, and may override properties of the referenceContext. See Image Hint Dictionary Keys for a summary of the possible key-value pairs.

Return Value

The image representation that most closely matches the specified criteria.

See Also

Working with Image Representations

func addRepresentation(NSImageRep)

Adds the specified image representation object to the image.

func addRepresentations([NSImageRep])

Adds an array of image representation objects to the receiver.

var representations: [NSImageRep]

An array containing all of the receiver's image representations.

func removeRepresentation(NSImageRep)

Removes and releases the specified image representation.

struct NSImageRep.HintKey

Constants for the keys to include in a hints dictionary when drawing the image.

enum NSImage.LayoutDirection

The layout direction for the image.