Subclassing NSButtonCell without using Interface Builder

Discussion in 'Mac Programming' started by Marimuthu, Aug 18, 2011.

  1. Marimuthu macrumors member

    Joined:
    Oct 18, 2010
    #1
    Hi All,

    I am developing an MAC application in Snow Leopard.
    I want to subclass NSButtonCell to get the desired look and feel. I found many sample projects which subclass NSButtonCell class (and over-ride required methods) and but they are linked to the button object on the app using Interface Builder. With this IB linking, all I need to do is implement methods like - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView
    and drawImage and the framework will take care of calling the methods.

    In my case, I need to dynamically create NSButton object as the number of buttons that I need to create vary from time to time. Also I need to dynamically skin each button with an image file. How do I do this without using IB?

    Regards,
     
  2. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    Check the documentation for "initWithView" to create the button objects and "addSubview" to add them to a window.
     

Share This Page