Here's how to do it in Swift
This answer is based on Mark "SBSLiderCell" answer above, but adapted for Swift.
Since it is a subclass of NSSliderCell, be sure to set your own class in Interface Builder for the cell, not NSSlider supervision.
Set the number of mark marks to the desired level of detail (for example, 100) and check the box "Only stop marks".
class PraxSliderCell : NSSliderCell { var lastSliderValue: Double = -1 override func closestTickMarkValueToValue(value: Double) -> Double { var proposedValue = super.closestTickMarkValueToValue(value) if lastSliderValue == -1 { lastSliderValue = proposedValue } else { let tickDifference = abs(lastSliderValue - proposedValue) let isTurningUp = proposedValue > lastSliderValue if tickDifference > Double(numberOfTickMarks / 2) { proposedValue = isTurningUp ? 0.0 : maxValue } print (NSString(format: "value: %.2f gap: %.2f", proposedValue, tickDifference)) lastSliderValue = proposedValue } return proposedValue } override func rectOfTickMarkAtIndex(index: Int) -> NSRect { return NSZeroRect } }
source share