CocoaPods trunk is moving to be read-only. Read more on the blog, there are 8 months to go.

PGLevelIndicator 1.1.0

PGLevelIndicator 1.1.0

Maintained by Pablo Garcia.




PGLevelIndicator

License Platform

A swift component that shows levels of whatever you want.

Requirements

  • Swift 4.2

Example Project

You have a fully functional demo in PGLevelIndicator folder

Install

Manually

Just drag and drop Source folder in your project

Cocoapods

use_frameworks!
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
self.view.addSubview(levelIndicator!)

And voilá....

Support/Issues

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

License

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.