UISlider clone with multiple thumbs and values, optional snap intervals, optional value labels.
let slider = MultiSlider()
slider.minimumValue = 1 // default is 0.0
slider.maximumValue = 5 // default is 1.0
slider.snapStepSize = 0.5 // default is 0.0, i.e. don't snap
slider.value = [1, 4.5, 5]
slider.addTarget(self, action: #selector(sliderChanged(_:)), forControlEvents: .ValueChanged)
func sliderChanged(slider: MultiSlider) {
print("\(slider.value)")
}
slider.thumbImage = UIImage(named: "baloon")
slider.minimumImage = UIImage(named: "clown")
slider.maximumImage = UIImage(named: "cloud")
slider.trackWidth = 5
slider.tintColor = .cyanColor()
slider.valueLabelPosition = .Left // .NotAnAttribute = don't show labels
slider.isValueLabelRelative = true // shows differences instead of absolute values
slider.disabledThumbIndices = [1, 3]
pod 'MultiSlider'
Copy Sources/MultiSlider.swift
and MiniLayout.swift
to your Xcode project.
- Horizontal slider and not just vertical.
-
isContinuous=false
for clients that only want a single.valueChanged
event on drag end. - Fix IB presentation. (dlopen error "image not found", thumbs should be vertically centered and evenly distributed.)