cocoansscroller

How to make knob track of a NSScroller transparent?


enter image description here

This is my application screenshot.There is only one NSScrollView on the window.I have made the other parts of the scrollview transparent,except the knob slot.

Here is my draw code for custom NSScroller subclass.

- (void) drawRect: (NSRect)dirtyRect
{
    [[NSColor clearColor] set];
    NSRectFill(dirtyRect);

    [self drawKnob];
}

Does anyone have a clue to make this work? Thanks a lot.


Solution

  • OK,I solve this myself.Here is the code.

    - (void) drawRect: (NSRect)dirtyRect
    {
        NSDrawWindowBackground([self bounds]);
        [self drawKnob];
    }
    

    Though it is not really transparent, but the effect is what I want.