<!--
{
  "documentType" : "article",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/convenience-functions",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Convenience Functions"
}
-->

# Convenience Functions

Draw rectangles and other primitive shapes using these convenience functions.

## Topics

### Drawing Rectangles

[`extern void NSFrameRect(NSRect rect);`](/documentation/AppKit/NSFrameRect)

Draws a bordered rectangle.

[`extern void NSFrameRectWithWidth(NSRect rect, CGFloat frameWidth);`](/documentation/AppKit/NSFrameRectWithWidth)

Draws a bordered rectangle.

[`extern void NSFrameRectWithWidthUsingOperation(NSRect rect, CGFloat frameWidth, NSCompositingOperation op);`](/documentation/AppKit/NSFrameRectWithWidthUsingOperation)

Draws a bordered rectangle using the specified compositing operation.

[`func NSEraseRect(NSRect)`](/documentation/AppKit/NSEraseRect(_:))

Erases the specified rect by filling it with white.

[`extern void NSRectFill(NSRect rect);`](/documentation/AppKit/NSRectFill)

Fills the passed rectangle with the current color.

[`extern void NSRectFillList(const NSRect *rects, NSInteger count);`](/documentation/AppKit/NSRectFillList)

Fills the rectangles in the passed list with the current fill color.

[`extern void NSRectFillListUsingOperation(const NSRect *rects, NSInteger count, NSCompositingOperation op);`](/documentation/AppKit/NSRectFillListUsingOperation)

Fills the rectangles in a list using the current fill color and specified compositing operation.

[`extern void NSRectFillListWithColors(const NSRect *rects, NSColor * const*colors, NSInteger num);`](/documentation/AppKit/NSRectFillListWithColors)

Fills the rectangles in the passed list with the passed list of colors.

[`extern void NSRectFillListWithColorsUsingOperation(const NSRect *rects, NSColor * const*colors, NSInteger num, NSCompositingOperation op);`](/documentation/AppKit/NSRectFillListWithColorsUsingOperation)

Fills the rectangles in a list using the specified colors and compositing operation.

[`extern void NSRectFillListWithGrays(const NSRect *rects, const CGFloat *grays, NSInteger num);`](/documentation/AppKit/NSRectFillListWithGrays)

Fills the rectangles in the passed list with the passed list of grays.

[`extern void NSRectFillUsingOperation(NSRect rect, NSCompositingOperation op);`](/documentation/AppKit/NSRectFillUsingOperation)

Fills a rectangle using the current fill color and the specified compositing operation.

[`func NSDrawTiledRects(NSRect, NSRect, UnsafePointer<NSRectEdge>, UnsafePointer<CGFloat>, Int) -> NSRect`](/documentation/AppKit/NSDrawTiledRects(_:_:_:_:_:))

Draws rectangles with borders.

[`func NSDrawGroove(NSRect, NSRect)`](/documentation/AppKit/NSDrawGroove(_:_:))

Draws a gray-filled rectangle with a groove border.

[`extern void NSHighlightRect(NSRect rect);`](/documentation/AppKit/NSHighlightRect)

Highlights the specified rect by filling it with white.

### Drawing Bezels

[`func NSDrawDarkBezel(NSRect, NSRect)`](/documentation/AppKit/NSDrawDarkBezel(_:_:))

Draws a dark gray-filled rectangle with a bezel border.

[`func NSDrawGrayBezel(NSRect, NSRect)`](/documentation/AppKit/NSDrawGrayBezel(_:_:))

Draws a gray-filled rectangle with a bezel border.

[`func NSDrawLightBezel(NSRect, NSRect)`](/documentation/AppKit/NSDrawLightBezel(_:_:))

Draws a white-filled rectangle with a bezel border.

[`func NSDrawWhiteBezel(NSRect, NSRect)`](/documentation/AppKit/NSDrawWhiteBezel(_:_:))

Draws a white-filled rectangle with a bezel border.

### Drawing Backgrounds

[`func NSDrawButton(NSRect, NSRect)`](/documentation/AppKit/NSDrawButton(_:_:))

Draws a gray-filled rectangle representing a user-interface button.

[`func NSDrawWindowBackground(NSRect)`](/documentation/AppKit/NSDrawWindowBackground(_:))

Draws the window’s default background pattern into the specified rectangle of the currently focused view.

### Drawing Multipart Images

[`func NSDrawNinePartImage(NSRect, NSImage?, NSImage?, NSImage?, NSImage?, NSImage?, NSImage?, NSImage?, NSImage?, NSImage?, NSCompositingOperation, CGFloat, Bool)`](/documentation/AppKit/NSDrawNinePartImage(_:_:_:_:_:_:_:_:_:_:_:_:_:))

Draws a nine-part tiled image.

[`func NSDrawThreePartImage(NSRect, NSImage?, NSImage?, NSImage?, Bool, NSCompositingOperation, CGFloat, Bool)`](/documentation/AppKit/NSDrawThreePartImage(_:_:_:_:_:_:_:_:))

Draws a three-part tiled image.

### Clipping Rectangles

[`extern void NSRectClip(NSRect rect);`](/documentation/AppKit/NSRectClip)

Modifies the current clipping path by intersecting it with the passed rect.

[`extern void NSRectClipList(const NSRect *rects, NSInteger count);`](/documentation/AppKit/NSRectClipList)

Modifies the current clipping path by intersecting it with the passed rect.

### Drawing Focus Rings

[`func set()`](/documentation/AppKit/NSFocusRingPlacement/set())

Specifies how the system draws the focus ring.

[`enum NSFocusRingPlacement`](/documentation/AppKit/NSFocusRingPlacement)

Constants that indicate how the system draws the focus ring.

[`enum NSFocusRingType`](/documentation/AppKit/NSFocusRingType)

Constants that describe the style of the focus ring.



---

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)