Signal Strength Indicator in Swift
I would like to tell about a UI component, which shows an indicator of the connectivity, like a standard iOS cellular indicator. Maybe be helpful for somebody. The control has simple customization: color, edges, spacing.
Installation
CocoaPods:
pod 'SignalStrengthIndicator'
Manual:
Copy SignalStrengthIndicator.swift to your project.
Usage
There is an example in the repository. The example shows how to add the control via storyboard (Interface Builder). Also, I can easily add via code.
let indicator = SignalStrengthIndicator()// Set up frameview.addSubview(indicator)
For controling the level of the indicator you need to use the following property:
indicator.level = .good
There is 6 cases of indication:
enum Level: Int {
case noSignal
case veryLow
case low
case good
case veryGood
case excellent
}
Customization
Color:
indicator.color = UIColor.gray
Spacing between bars:
indicator.spacing = 5
Margins:
indicator.edgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
The example and source code of the UI control you can find here.