Latest 1.1.0
Homepage https://github.com/pablogsIO/PGLevelIndicator
License MIT
Platforms ios 10.0, requires ARC
Frameworks UIKit

PGLevelIndicator

PGLevelIndicator
PGLevelIndicator
License
Platform

A swift component that shows levels of whatever you want.

PGLevelIndicator

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á….

PGLevelIndicator

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.

Latest podspec

{
    "name": "PGLevelIndicator",
    "version": "1.1.0",
    "summary": "Fancy and beautiful level indicator component for you awesome apps!",
    "homepage": "https://github.com/pablogsIO/PGLevelIndicator",
    "license": "MIT",
    "authors": "Pablo Garcia",
    "source": {
        "git": "https://github.com/pablogsIO/PGLevelIndicator.git",
        "tag": "1.1.0"
    },
    "screenshots": [
        "https://raw.githubusercontent.com/pablogsIO/PGLevelIndicator/master/Assets/levelindicator.gif"
    ],
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "Source/*.swift",
    "frameworks": "UIKit",
    "swift_version": "4.2",
    "requires_arc": true,
    "social_media_url": "https://twitter.com/_pablogs_"
}

Pin It on Pinterest

Share This