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) // continuous changes
slider.addTarget(self, action: #selector(sliderDragEnded(_:)), forControlEvents: . touchUpInside) // sent when drag ends
func sliderChanged(slider: MultiSlider) {
print("\(slider.value)") // e.g., [1.0, 4.5, 5.0]
}
slider.orientation = .horizontal
slider.thumbImage = UIImage(named: "balloon")
slider.minimumImage = UIImage(named: "clown")
slider.maximumImage = UIImage(named: "cloud")
slider.tintColor = .cyan
slider.trackWidth = 5
slider.hasRoundTrackEnds = true
slider.showsThumbImageShadow = false
slider.valueLabelPosition = .Left // .NotAnAttribute = don't show labels
slider.isValueLabelRelative = true // shows differences instead of absolute values
slider.disabledThumbIndices = [1, 3]
- iOS 9.0+
- Xcode 9
pod 'MultiSlider'
For legacy Swift 2.3:
pod 'MultiSlider', '~> 1.0.1'
Copy Sources/*.swift
and MiniLayout.swift
to your Xcode project.
- Fix IB presentation. (dlopen error "image not found", thumbs should be vertically centered and evenly distributed.)