UIControl slider that can be dragged from any point within its bounds, similar to those in Control Center and Home.app
A slider control designed to be easy to grab and use because it can be dragged or tapped from anywhere along its track, similar to the sliders in Control Center and HomeKit. Because this type of slider graphically represents direct manipulation of a value, it should be used for live adjustment of values whose changes can be directly observed in real time (such as audio volume or the brightness of a light).
To run the example project, clone the repo, and run
pod installfrom the Example directory first.
iOS 8.0+
TactileSlider is available as a Swift package or through CocoaPods.
To install it using CocoaPods, simply add the following line to your Podfile:
pod 'TactileSlider'
let slider = TactileSlider(frame: someRect)slider.minimumValue = 1 slider.maximumValue = 10
slider.setValue(3.8, animated: true)
slider.vertical = true slider.reverseValueAxis = true
slider.isContinuous = false slider.enableTapping = false // allow or disallow tapping anywhere on the slider track to instantly set a value slider.feedbackStyle = .medium // customize haptic feedback slider.isScrollingEnabled = false // allow or disallow scrolling to adjust the slider using a connected pointing device on iPadOS
slider.trackBackground = UIColor.black.withAlpha(0.8) // use translucent black for the slider track slider.tintColor = UIColor.systemGreen // use dynamic green for the slider thumb slider.cornerRadius = 12 slider.isPointerInteractionEnabled = true // display a hover effect when under the pointer on iPadOS
Dale Price (@[email protected])
TactileSlider is available under the MIT license. See the LICENSE file for more info.