JOCircularSlider
JOCircularSlider is a highly customisable and reusable iOS circular slider that mimics the behaviour of a knob control. It uses no preset images and every one of its components is drawn completely in code making it extremely adaptable to every design and theme.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- iOS 10.0+
- Xcode 10.0
Installation
JOCircularSlider is available through CocoaPods. To install
it, simply add the following line to your Podfile:
JOCircularSlider is also available through Carthage. To install it, simply add the following line to your Cartfile:
Usage
- Visually:
Drag a UIView to your storyboard, change its class of to CircularSlider and start visually customising the design to your liking.
All the parameters are IBInspectable, so you can configure the slider straight from the attribute inspector tab, without having to write a single line of code.
- Programatically:
These are just few of the many params you can configure for the slider.
The slider's min/max values are IBInspectable and default to 0.0 and 100.0 respectively.
They also support negative and positive values or a mixture of them.
The slider's value
property is both { get set } and it is designed to work similarly to the familiar value property of UIKit's generic UISlider.
In order to get value change notifications, use the Target-Action
pattern which is an inherent part of UIControl, like so:
To Control the appearance of the label displaying the value, use these:
You can also specify the number of decimal places this label should show.
The default is 0.0 unless for example the value is within [0.0, 1.0]
If you need to override the text in the label, then just implement the following function inside the selector of the Target-Action
method for the event UIControl.Event.valueChanged
Author
Jalal Ouraigua, ouraigua@icloud.com