Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mark FX

macrumors regular
Original poster
Nov 18, 2011
159
17
West Sussex, UK
Hi everyone

I have been getting to grips with Objective-C and Xcode over the past six months, after coming
from other languages.

I wanted to know if anyone has help for customising the NSSlider, I see from the doc's that the
NSSlider class has no methods, for changing its appearance, specifically I wanted to change
the slider knob image, and possibly the slider image color.

I have found resources on the Web for the iOS UISlider customising, but none for the OSX
NSSlider, any pointers to other resources would be great, or a resource for custom controls.

Many Thanks

Regards Mark
 
You need to subclass NSSliderCell instead, and tell your NSSlider to use the subclass. It should be fairly easy to pick out what methods you need to override from the NSSliderCell class reference.
 
Thanks for the advise Josh.

I think the main problem with the NSSlider class is, that it has no methods to
change its image's appearance, but I shall keep trying.

Regards Mark
 
Thanks for the advise Josh.

I think the main problem with the NSSlider class is, that it has no methods to
change its image's appearance, but I shall keep trying.

Regards Mark

You did notice the difference right? NSSlider verses NSSliderCell. This is a common pattern in Cocoa. The control class is just a container for a cell and it's actually the cell that does the drawing.

You can change the knob but subclassing NSSliderCell and overriding the - (void)drawKnob:(NSRect) method.
 
Thanks jiminaus, for steering me in the right direction.

I was looking at the NSSlider doc's, and not at the NSSliderCell doc's.


Regards Mark
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.