Initializer

init(contextSize:currentContextDrawing:)

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

Declaration

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

Parameters

contextSize

The desired size of the context passed to the drawing block. The size should 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 is scaled to QLFileThumbnailRequest’s scale property. For example, if you pass a contextSize of CGSize(10, 10) to this method, the size of the context is (scale * 10, scale * 10).

drawingBlock

A block that draws the thumbnail into the current CGBitmapContext context that’s accessible via UIGraphicsGetCurrentContext() or, if you’re developing for macOS, NSGraphicsContext.current. Use the context with the coordinate system of UIKit or AppKit.

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

Return Value

An initialized reply object for a requested thumbnail.

Discussion

Create a thumbnail using a drawing block and a given context with the coordinate system of UIKit or AppKit.

See Also

Creating a Thumbnail

init(contextSize: CGSize, drawing: (CGContext) -> Bool)

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

init(imageFileURL: URL)

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