GNGaugeView
A visual gauge built with Swift that can be used as a speedometer to track speed of travel. Useful for giving a visual display of the speed of walking, running or any other kind of fitness activity.
Installing
$ pod install GNGaugeView
or in your Podfile
pod 'GNGaugeView'
Usage
Subclass a UIView with GNGaugeView in Storyboard or instantiate a GNGaugeView. Specify any desired configurations such as a minimum and maximum speed for your gauge. Use the function rotateGauge(newSpeed: CGFloat) to rotate the gauge to a new speed. In the example below we use a UISlider to rotate the gauge:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var gaugeView: GNGaugeView!
@IBOutlet weak var gaugeSlider: UISlider!
override func viewDidLoad() {
super.viewDidLoad()
gaugeView.minSpeed = 0
gaugeView.maxSpeed = 30
}
@IBAction func sliderDidChange(_ sender: UISlider) {
let sliderValue = sender.value
let speed = gaugeView.maxSpeed * CGFloat(sliderValue)
gaugeView.rotateGauge(newSpeed: speed)
}
}
Example
An example project is included which shows how to use GNGaugeView with Core Motion to get the speed of walking or running.
Authors
- Gwinyai Nyatsoka - Initial work - Gwinyai
License
This project is licensed under the MIT License - see the LICENSE.md file for details.