Initializer

init(contextSize:drawing:)

Creates a new thumbnail for a custom file type in the given context.

Declaration

convenience init(contextSize: CGSize, drawing drawingBlock: @escaping (CGContext) -> Bool)

Parameters

contextSize

The desired size of the context passed to the drawing block. It needs be as close as possible to the maximumSize of the QLFileThumbnailRequest and has to be greater than or equal to its minimumSize.

This parameter indicates the preferred size of the thumbnail that you need to create. The context’s width or its height matches the width or height of the maximumSize, or, ideally, both.

The context size will be scaled to QLFileThumbnailRequest scale property. For example, if you pass a contextSize of CGSize(10, 10) to this method, the size of the context will be (scale * 10, scale * 10).

drawingBlock

The context for drawing the thumbnail.

context

A context of type CGBitmapContext that uses the coordinate system provided by Core Graphics.

Return true if the thumbnail was successfully drawn into the context. Return false otherwise.

Return Value

An initialized reply object for a requested thumbnail.

Discussion

Create a thumbnail using a drawing block and a context with the coordinate system of Core Graphics.

See Also

Creating a Thumbnail

init(contextSize: CGSize, currentContextDrawing: () -> Bool)

Creates a new thumbnail for a custom file type in the current context.

init(imageFileURL: URL)

Creates a new thumbnail for a custom file type using a file at the given URL.