To run the example project, run
pod try SGauge.
-iOS SDK 9.0 or later
SGauge is available through CocoaPods. To install it, simply add the following line to your Podfile:
How to use
Add an UIView from ‘Object Library’ of 'Utilities’
Click the view you’ve just added and set the both class and module of the view to 'SGauge’. You shall see the gauge then.
Customize gauge’s appearance through Attribute Inspector
Declare a property of type SGauge with @IBOutlet qualifier in your view controller. For instance:
@IBOutlet var gauge: SGauge!
- Connect the gauge with the property through Interface Builder.
- To move the needle, simply assign a value to the gauge. For instance:
gauge.value = CGFloat(50)
- Max Value: The maximum value expressible for the gauge (Default: 100).
- Min Value: The minimum value expressible for the gauge (Default: 0).
- Arc Color: The color of the arc of the gauge (Default: clear).
- Arc Outline Color: The color of the outline of the arc (Default: black).
- Needle Color: The color of the gauge’s needle (Default: red).
- Arc Width: The thickness of the arc (Default: 20).
- Arc Outline Width: The thickness of the arc’s outline (Default: 1).
- Needle Width: The thickness of the needle (Default: 1).
- Graduation Unit: The inteval between graduation marks, denoted by value (Default: 10).
- Graduation Length: The length of graduation marks (Default: 10).
- Additional Needle Length: You may change needle length by adjusting this value (Default: 0).
- Animation Duration: The duration of needle’s rotation when the gauge’s value changed (Default: 0.1 sec).
Luis Wu, [email protected]
SGauge is available under the MIT license. See the LICENSE file for more info.