Search code examples
cocoasubclassingnsbox

Subclassing NSBox


How could I subclass a NSBox to change the width, height , font type and background color of the Box's title?.


Solution

  • Most of those look like they can be set with simple calls to NSBox's accessors, and the size and background color can be set by calling [myBox title] then calling the appropriate methods on the returned NSCell.

    So subclassing NSBox to do all of these things would be as simple as setting the right properties in -init, and making sure to override the methods listed in the "Subclassing Notes" section within NSBox's Class Reference.