I've had a similar simple class for a while, so that inspired me to push it to GitHub as open source, too. My variation provides four new properties, to set either or both the background and border colors:

Adds a drawsBackground BOOL property. Defaults to YES.

Adds a drawsBorder BOOL property. Defaults to YES.

Adds a backgroundColor NSColor property. Defaults to nil, but lazily assigns a light blue color if not set to another color.

Adds a borderColor NSColor property. Defaults to nil, but lazily assigns a light gray color if not set to another color.

IB_DESIGNABLE support for all four properties, so they can be set in Interface Builder.

To use it, simply include the DejalBackgroundView.h and DejalBackgroundView.m files in your project, then change a container NSView to DejalBackgroundView in the view hierarchy, and set the colors as desired (via code or IB), e.g.:

self.backgroundView.backgroundColor = [NSColor lightGrayColor];

If you only want a background without a border, easily turn off the border drawing:

self.drawsBorder = NO;

All of these properties can be set in IB thanks to the IB_DESIGNABLE and IBInspectable attributes in Xcode 6.

As a bonus, the view is automatically treated as opaque if the background color is used, and is itself opaque.

(I've been meaning to push out more of my code as open source; I would like to take the time to release more, to give back to the community. Please let me know if you read this and would like to encourage me to do so.)