Radial Gauge is a custom UI component that consists of five layers:
- High thumb layer - Used for sliding and changing value.
- Low thumb layer - Used for sliding and changing value.
- Indicator layer - Used for showing the current value (for example current temperature).
- Progress track layer - Layer which will follow current value on both sides.
- Background track layer - Static layer below the progress layer.
To run the example project, clone the repo, and run pod install
from the Example directory first.
RadialGauge is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RadialGauge'
Radial Gauge can be configured as:
- single-mode,
- dual-mode or
- as a circular progress bar
Single-mode
Single-mode is a Radial Gauge with one thumb to control the slider.
Dual-mode
Dual-mode is a Radial Gauge with two thumbs to control the slider.
Circular progress bar
Circular progress bar is a Radial Gauge without thumbs. This can be useful for showing progress without user interaction.
These properties can be configured to update UI:
- Progress track layer color or gradient,
- Background track layer color,
- Indicator and thumb color,
- Indicator, thumb and track width
let radialGauge = RadialGauge()
// Set background color
radialGauge.progressLayerColor = .red
radialGauge.backgroundTrackColor = .grey
radialGauge.highThumbColor = .white
radialGauge.lowThumbColor = .white
radialGauge.indicatorColor = .black
// Set gradient
radialGauge.gradientColors = viewModel.progressLayerGradient
// Set width
radialGauge.lineWidth = 15
radialGauge.highThumbLineWidth = 10
radialGauge.lowThumbLineWidth = 10
radialGauge.indicatorLineWidth = 10
//Set length
radialGauge.highThumbLength = 24
radialGauge.lowThumbLength = 24
radialGauge.indicatorLength = 24
Handle values
For dual-mode few properties can be configured to Radial Gauge work properly:
- Low thumb minimum and maximum value
- High thumb minimum and maximum value
- Step size - Determines for how much will thumb change its value
- Deadband - Maximum distance between two thumbs
Radial Gauge follows these rules:
- One thumb cannot overlap another thumb.
- The low thumb will be shown only between its minimum and maximum value
- The high thumb will be shown only between its minimum and maximum value
- The maximum value of the radial gauge will be a greater maximum value of both thumbs
- The minimum value of the radial gauge will be a smaller minimum value of both thumbs
One thumb cannot overlap another thumb. To prevent this, Radial Gauge has deadband property. This property defines the maximum distance between two thumbs. If this distance is reached then one thumb pushes another thumb. This can be disabled using enableDualMovement() function call.
// Set low thumb
radialGauge.setLowThumbMaximumValue(50)
radialGauge.setLowThumbMinimumValue(0)
radialGauge.setLowThumbStepSize(1)
// Set high thumb
radialGauge.setHighThumbMaximumValue(100)
radialGauge.setHighThumbMinimumValue(0)
radialGauge.setHighThumbStepSize(1)
radialGauge.enableDualMovement(false)
radialGauge.setThumbStepSize(1)
radialGauge.setDeadband(1)
We can set a value for thumbs and the indicator.
// Set value for thumbs
radialGauge.handleThumbValue(value: 20, thumbType: .lowThumb)
radialGauge.handleThumbValue(value: 50, thumbType: .highThumb)
// Set value for indicator
radialGauge.setIndicatorValue(50)
RadialGauge is available under the MIT license. See the LICENSE file for more info.