Level indicator
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets README Update Jan 22, 2019
Source podspec Jan 23, 2019
.gitignore Initial commit Oct 15, 2018
LICENSE Initial commit Oct 15, 2018
PGLevelIndicator.podspec podspec Jan 23, 2019
README.md README update Jan 23, 2019



License Platform

A swift component that shows levels of whatever you want.


  • Swift 4.2

Example Project

You have a fully functional demo in PGLevelIndicator folder



Just drag and drop Source folder in your project


pod 'PGLevelIndicator'

Using PGLevelIndicator

  • Create attributed strings with the text you want
let font: UIFont? = UIFont(name: "Avenir-Book", size: 18)
let fontSuper: UIFont? = UIFont(name: "Avenir-Book", size: 10)
let attStringNO2 = NSMutableAttributedString(string: "NO2", attributes: [.font: font!])

attStringNO2.setAttributes([.font: fontSuper!, .baselineOffset: -5],
                          range: NSRange(location: 2, length: 1))
  • Create an array of parameters:
let parameters = [ItemParameters(title: attStringNO2, titleColor: UIColor.red, level: .low),
                  ItemParameters(title: attStringO3, titleColor: UIColor.yellow, level: .medium),
                  ItemParameters(title: attStringpM10, titleColor: UIColor.green, level: .high),
                  ItemParameters(title: attStringPM25, titleColor: UIColor.orange, level: .low)]

(The level parameter is not used, but maybe in future revisions we will use it)

  • Create the PGLevelIndicator object:
let levelIndicator = PGLevelIndicator(frame: CGRect(x: 0,
                                                    y: 100,
                                                    width: self.view.frame.size.width,
                                                    height: self.view.frame.size.width),
                                      itemsParameters: parameters)
  • And finally, add the levelIndicator to the main view

And voilá....


If you have any questions, please don't hesitate to create an issue.


PGLevelIndicator is available under the MIT license. See the LICENSE file for more info.

If you use it, I'll be happy to know about it.