<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuickLookThumbnailing",
  "identifier" : "/documentation/QuickLookThumbnailing/QLThumbnailReply/init(contextSize:drawing:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Quick Look Thumbnailing"
    ],
    "preciseIdentifier" : "c:objc(cs)QLThumbnailReply(cm)replyWithContextSize:drawingBlock:"
  },
  "title" : "init(contextSize:drawing:)"
}
-->

# init(contextSize:drawing:)

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

```
convenience init(contextSize: CGSize, drawing drawingBlock: @escaping (CGContext) -> 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 [`QLFileThumbnailRequest`](/documentation/QuickLookThumbnailing/QLFileThumbnailRequest) class’s [`maximumSize`](/documentation/QuickLookThumbnailing/QLFileThumbnailRequest/maximumSize) value and greater than or equal to its [`minimumSize`](/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 [`maximumSize`](/documentation/QuickLookThumbnailing/QLFileThumbnailRequest/maximumSize)    , or, ideally, both.

    The system scales the context size to the [`QLFileThumbnailRequest`](/documentation/QuickLookThumbnailing/QLFileThumbnailRequest)     class’s [`scale`](/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`

The context for drawing the thumbnail. The block takes the following parameter:

- context: A context of type <doc://com.apple.documentation/documentation/CoreGraphics/CGContext> that uses the coordinate system provided by <doc://com.apple.documentation/documentation/CoreGraphics>.

    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

An initialized reply object for a requested thumbnail.

## Discussion

Use this initializer if you’re drawing the thumbnail using <doc://com.apple.documentation/documentation/CoreGraphics>. If you’re using <doc://com.apple.documentation/documentation/UIKit> or <doc://com.apple.documentation/documentation/AppKit> to draw the thumbnail, use the initializer [`init(contextSize:currentContextDrawing:)`](/documentation/QuickLookThumbnailing/QLThumbnailReply/init(contextSize:currentContextDrawing:)). The context that this initializer provides uses the coordinate system of <doc://com.apple.documentation/documentation/CoreGraphics>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)