---
title: "init(contextSize:currentContextDrawing:)"
framework: quicklookthumbnailing
role: symbol
role_heading: Initializer
path: "quicklookthumbnailing/qlthumbnailreply/init(contextsize:currentcontextdrawing:)"
---

# init(contextSize:currentContextDrawing:)

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

## Declaration

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

## Parameters

- `contextSize`: The desired size of the context that you pass to the drawing block. Set this value as close as possible to the doc://com.apple.quicklookthumbnailing/documentation/QuickLookThumbnailing/QLFileThumbnailRequest class’s doc://com.apple.quicklookthumbnailing/documentation/QuickLookThumbnailing/QLFileThumbnailRequest/maximumSize value and greater than or equal to its doc://com.apple.quicklookthumbnailing/documentation/QuickLookThumbnailing/QLFileThumbnailRequest/minimumSize value. This parameter indicates the preferred size of the thumbnail. The context’s width or its height matches the width or height of the doc://com.apple.quicklookthumbnailing/documentation/QuickLookThumbnailing/QLFileThumbnailRequest/maximumSize, or, ideally, both. The system scales the context size to the doc://com.apple.quicklookthumbnailing/documentation/QuickLookThumbnailing/QLFileThumbnailRequest class’s doc://com.apple.quicklookthumbnailing/documentation/QuickLookThumbnailing/QLFileThumbnailRequest/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 bitmap doc://com.apple.documentation/documentation/CoreGraphics/CGContext that’s accessible using doc://com.apple.documentation/documentation/UIKit/UIGraphicsGetCurrentContext() or, if you’re developing for macOS, NSGraphicsContext.current. Use the context with the coordinate system of doc://com.apple.documentation/documentation/UIKit or doc://com.apple.documentation/documentation/AppKit. Return doc://com.apple.documentation/documentation/Swift/true if you successfully drew the thumbnail into the context. Return doc://com.apple.documentation/documentation/Swift/false otherwise.

## Return Value

Return Value An initialized reply object for a requested thumbnail.

## Discussion

Discussion Use this initializer if you’re drawing the thumbnail using UIKit or AppKit. If you’re using CoreGraphics to draw the thumbnail, use init(contextSize:drawing:). The context that this initializer provides uses the coordinate system of UIKit or AppKit, depending on the platform.

## See Also

### Creating a Thumbnail

- [init(contextSize:drawing:)](quicklookthumbnailing/qlthumbnailreply/init(contextsize:drawing:).md)
- [init(imageFileURL:)](quicklookthumbnailing/qlthumbnailreply/init(imagefileurl:).md)
