Skip to content

Simple, clean, and customizable range-based slider control for macOS

Notifications You must be signed in to change notification settings

matthewreagan/RangeSlider

Repository files navigation

RangeSlider

Styles

RangeSlider is a clean, simple, and attractive range-based slider control for Mac, written in Swift.

It is similar to NSSlider except that it affords two control points (start and end knobs), useful when users need to select a range of values.

Features:

  • Simple, easy-to-use
  • Flexible resizing
  • Customizable
  • Snap-to-interval (optional)
  • Several built-in styles

Demo

RangeSlider Demo

How To Use

  1. Add to XIB or create programmatically. Example: let slider = RangeSlider(frame:sliderFrame)
  2. (Optional) Set the min/max values (default: 0.0-1.0)
  3. (Optional) Set the start/end values (default: 0.0-1.0)
  4. (Optional) Enable snapping (snapsToIntegers = true)
  5. (Optional) Adjust style options (colorStyle, knobStyle)

Responding to Changes

Once the slider is configured, you can respond to changes by observing the start/end (or length) values, or using the onControlChanged property.

Example:

mySlider.onControlChanged = {
    (slider: RangeSlider) -> Void in
    print("Slider changed! Start:\(slider.start) End:\(slider.end) Range:\(slider.length)")
}

ToDo's

RangeSlider is still a work-in-progress. A few of the known issues / ToDo's remaining:

  • Fix clipping of knob shadows, especially for circular slider style
  • General cleanup, refactoring
  • Fix knobs being allowed to overlap
  • Improve border stroke of circular knob style
  • Accessibilty support + highlighting/focus and other control behaviors

System Requirements

RangeSlider is currently macOS-only, however it could easily be updated to work with UIKit. Please file an Issue or feel free to submit a Pull Request if you'd like iOS support.

Author

Matt Reagan - Website: http://sound-of-silence.com/ - Twitter: @hmblebee

License

RangeSlider's source code and related resources are Copyright (C) Matthew Reagan 2016. The source code is released under the MIT License. If you use RangeSlider in any publicly-distributed applications please include attribution.

About

Simple, clean, and customizable range-based slider control for macOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages