How to draw a transparent NSScroller

I will subclass NSScroller to try to make it look like the scrollbar on iOS. I want this to just be an overlay representing the current position, which is drawn on top of what's below it. For some reason, if I override the drawRect for the scroller, I get borders filled with white. Is there a way to prevent this, so that I can just draw on top of the fact that my NSScroller subclass has ended?

Edit: A drawing with a clear color seems to bring me closer, but it draws "too clearly": P It draws directly to the desktop when I just want to minimize to the window. This picture can make it clearer. alt text

Any ideas?

+3
4

NSView , drawRect. , ( , ). , nob .

- (void)drawRect:(NSRect)dirtyRect {

    // Do some custom drawing...
    [[NSColor clearColor] set];
    NSRectFill(dirtyRect);

    // Call NSScroller drawKnob method (or your own if you overrode it)
    [self drawKnob];
  }

, ( , NSScroller.) NSScroller , / drawRect: ( apple docs: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSScroller_Class/Reference/Reference.html)

+9

, , ...

- (void) drawRect: (NSRect) dirtyRect
{
    [self drawKnob];
}
+4

RFOverlayScrollView, NSScroller, ; MIT.

RFOverlayScrollView

RFOverlayScrollView - NSScrollView, NSScroller iOS, .

enter image description here

+4

, , [super drawRect:rect], .

FWIW, , , NSScroller. iOS . super drawRect:, , iOS. , , .

If you want to reuse the Drawing snippets NSScroller, the class provides many methods for doing so, for example drawKnob, and drawArrow:highlight:etc.

0
source

Source: https://habr.com/ru/post/1774858/


All Articles