Hi,
I override the drawTickMarks() in NSSliderCell.
However, I need to draw some text there and may have a little outside the NSSlider's boundary, so I got some clip in my result.
I try to set the maskToBound to false by
self.controlView?.wantsLayer = true
self.controlView?.layer?.masksToBounds = false
self.controlView?.layer?.backgroundColor = CGColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
So I can clearly see the bounds of slider but the masksToBounds didn't work here.
Does anybody know to make the masksToBounds work for my purpose?
Thank you~~
I override the drawTickMarks() in NSSliderCell.
However, I need to draw some text there and may have a little outside the NSSlider's boundary, so I got some clip in my result.
I try to set the maskToBound to false by
self.controlView?.wantsLayer = true
self.controlView?.layer?.masksToBounds = false
self.controlView?.layer?.backgroundColor = CGColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
So I can clearly see the bounds of slider but the masksToBounds didn't work here.
Does anybody know to make the masksToBounds work for my purpose?
Thank you~~
I did this, with a slider named sliderWithTicks.cell
Code Block sliderWithTicks.cell?.controlView?.wantsLayer = true sliderWithTicks.cell?.controlView?.layer?.masksToBounds = false sliderWithTicks.cell?.controlView?.layer?.backgroundColor = CGColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5) let text = NSTextField(string: " 1 2 3 4") text.frame = NSRect(x: 0, y: -16, width: 100, height: 24) text.drawsBackground = false text.isBezeled = false text.isEditable = false sliderWithTicks.cell?.controlView?.addSubview(text)