Recommended way to Subclass NSView subclasses (NSButton, NSTextField, NSPopUpButton) for Custom Visuals

I've been wrestling with applying my custom styles (example) to the OSX desktop app I've been building, and I'm wondering what the paradigms/idioms are for doing this.

  • I'm using X/Nibs for laying out the components on the windows
  • I'm setting the components' class to a custom subclass of the out-of-the-box component (
    NSTextField
    ,
    NSButton
    , and
    NSPopUpButton
    for example)
  • I'm overriding
    viewWillDraw
    in some,
    init?
    in others and making them all
    wantsLayer
    and setting attributes on those layers

This seems extremely clumsy at best, and some visual things are impossible to handle this way, like adding padding to an

NSTextField
.


A lot of people are describing how to do certain changes to visual components in

viewDidLoad
with a reference to a component, which seems very tedious if you have button/textfield styles that apply to all in the project. It seems like every visual change I've made with subclassing has been a nightmare, and there's no pattern for what visual changes are made where for different components. Subclassing seems like the best option for any size of project if you want to make your code reusable, but am I missing something? Is there some other pattern or idiom that I'm missing?
Did you ever find a solution to this? I am struggling with the same thing for drawing a custom image for NSPopupButton items
Recommended way to Subclass NSView subclasses (NSButton, NSTextField, NSPopUpButton) for Custom Visuals
 
 
Q