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

# drawImage(_:withFrame:in:)

Draws the image associated with the button’s current state.

```
func drawImage(_ image: NSImage, withFrame frame: NSRect, in controlView: NSView)
```

## Parameters

`image`

The image associated with the button’s current state.

`frame`

The bounding rectangle of the button.

`controlView`

The control being drawn.

## Discussion

This method is called automatically when the button is redrawn; you should not call it directly.

You specify the primary and alternate images for the button using Interface Builder.

## See Also

[`alternateImage`](/documentation/AppKit/NSButtonCell/alternateImage)

The image the button displays in its alternate state.



---

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)