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

# drawBorderAndBackground(withFrame:in:)

Draws the borders and background associated with the receiver’s menu item (if any).

```
func drawBorderAndBackground(withFrame cellFrame: NSRect, in controlView: NSView)
```

## Parameters

`cellFrame`

A rectangle defining the receiver’s frame area.

`controlView`

The view object that contains this cell (usually an [`NSControl`](/documentation/AppKit/NSControl) object).

## Discussion

This method invokes the `NSCell` method [`imageRect(forBounds:)`](/documentation/AppKit/NSCell/imageRect(forBounds:)), passing it `cellFrame`, to calculate the rectangle in which to draw the image. The cell invokes this method before invoking the methods to draw the other menu item components.

## See Also

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

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



---

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)