Adding a custom view to toolbar

I'm struggling with Cocoa for 2 hours now without success. I want to add a custom view to the toolbar. So, I added a NSToolbar to the window (with IB), and added my view (which works perfectly). IB automatically created a NSToolbarItem. I followed the instructions from Apple here: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Toolbars/Tasks/AddRemoveToolbarItems.html#//apple_ref/doc/uid/20000755-BBCGJCDJ

The problem is that I don't know what to do now, the view doesn't show although it's label is displayed in the window.

Here's the code I use to draw (very simple, it's for testing purpose)

- (void)drawRect:(NSRect)dirtyRect {
    [[NSColor blackColor] set];
    [[NSBezierPath bezierPathWithRect:self.bounds] fill];
}

Can someone help me?

Thanks in advance.

13
задан 15 February 2011 в 19:33
поделиться