<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextAttachmentCellProtocol/draw(withFrame:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextAttachmentCell(im)drawWithFrame:inView:"
  },
  "title" : "draw(withFrame:in:)"
}
-->

# draw(withFrame:in:)

Draws the cell’s image in the specified rectangle of the currently focused view.

```
@MainActor func draw(withFrame cellFrame: NSRect, in controlView: NSView?)
```

## Parameters

`cellFrame`

The frame rectangle in which to draw.

`controlView`

The view in which to draw.

## See Also

[`draw(withFrame:in:)`](/documentation/AppKit/NSCell/draw(withFrame:in:))

Draws the receiver’s border and then draws the interior of the cell.

  [Text Attachment Programming Topics](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/TextAttachments/TextAttachments.html#//apple_ref/doc/uid/10000094i)

[`lockFocus()`](/documentation/AppKit/NSView/lockFocus())

Locks the focus on the view, so subsequent commands take effect in the view’s window and coordinate system.



---

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)