Skip to content

UISlider clone with multiple thumbs and values, optional snap intervals, optional value labels.

License

Notifications You must be signed in to change notification settings

carabina/MultiSlider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiSlider

UISlider clone with multiple thumbs and values, optional snap intervals, optional value labels.

Usage

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)

Getting Multiple Thumb Values

func sliderChanged(slider: MultiSlider) {
    print("\(slider.value)")
}

Changing Appearance

slider.thumbImage   = UIImage(named: "baloon")
slider.minimumImage = UIImage(named: "clown")
slider.maximumImage = UIImage(named: "cloud")
slider.trackWidth = 5
slider.tintColor = .cyanColor()

Adding Labels Showing Thumb Value

slider.valueLabelPosition = .Left // .NotAnAttribute = don't show labels
slider.isValueLabelRelative = true // shows differences instead of absolute values

Disabling/Freezing Thumbs

slider.disabledThumbIndices = [1, 3]

Installation

CocoaPods:

pod 'MultiSlider'

Manually:

Copy Sources/MultiSlider.swift and MiniLayout.swift to your Xcode project.

TODO

  • 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.)

About

UISlider clone with multiple thumbs and values, optional snap intervals, optional value labels.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 66.9%
  • Shell 27.5%
  • Objective-C 2.9%
  • Ruby 2.7%