Custom knob NSSliderCell OS X Swift

Viewed 474

Edit: I just read that cells are being deprecated post 10.10 (I guess I have to find an alternative method anyway)

I was wondering if someone could point me in the right direction for doing vector based (core animation/ graphics) custom controls in OS X using swift.

I have a NSSliderCell which I am trying to make look like this.

enter image description here

So far I have removed the bar by overriding the drawBar Method and leaving it empty.

And tried a bunch of different ways to draw the Knob (omitted from the code example) as a triangle. (its super simple but the documentation is really sparse.) but all so far have come with a mixed result of wrongness.

Could you point me towards good documentation for OS X or help me understand a little about the implementation please.

Kind Regards

Brian

class VolumeSliderCell: NSSliderCell {
    override func drawBar(inside rect: NSRect, flipped: Bool) {
        // NOTE: Deliberately left empty (Hides Bar!)
    }

    override func drawKnob(_ knobRect: NSRect) {
        if(controlView?.lockFocusIfCanDraw())! {
           // NOTE: What goes here?
        }
    }
}
0 Answers
Related