Create iTunes Scrollbars

Discussion in 'Mac Programming' started by Blakeasd, Jan 7, 2011.

  1. Blakeasd macrumors 6502a

    Dec 29, 2009
  2. kainjow Moderator emeritus


    Jun 15, 2000
    You'll need to subclass NSScroller and draw everything yourself. Study the NSScroller documentation and play around a ton with overriding the various drawing methods. I did this a little while back for work, so can't post any code, but I did override drawRect: where I manually call drawArrow:highlight:, drawKnob, and drawKnobSlotInRect:highlight: which were all overridden.
  3. Blakeasd, Jan 7, 2011
    Last edited: Jan 8, 2011

    Blakeasd thread starter macrumors 6502a

    Dec 29, 2009
  4. Blakeasd thread starter macrumors 6502a

    Dec 29, 2009
    I was able to do it! :)
    Here is the code I used for anyone who wants it:
    	NSRect knobRect = [self rectForPart:NSScrollerKnob];
    	NSRect newRect = NSMakeRect(knobRect.origin.x+1, knobRect.origin.y, knobRect.size.width - 2, knobRect.size.height);
    	NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:5 yRadius:5];
    	NSGradient * gradient = [[NSGradient alloc] initWithColorsAndLocations:[NSColor colorWithDeviceRed:(float)173/255 green:(float)185/255 blue:(float)203/255 alpha:1.0],0.0, 
    							 [NSColor colorWithDeviceRed:(float)117/255 green:(float)135/255 blue:(float)164/255 alpha:1.0], 1.0, nil];
    	[gradient drawInBezierPath:path angle:0];	

Share This Page