SCountLabel is an easy to use Swift extension counter for UILabel. There is no need to use custom class for your labels. :)
You can count integer or floatingpoints values
UILabel().count(to: "11")
UILabel().count(to: "11.0")
You can have multiple variaitons including few counting numbers in same string.
UILabel().count(to: "11 and second number in same string -22.0")
The values can be negative or positive. Typed as 2.0
or .2
what ever you like!
More over you can pass your own time interval between value changes in your string
UILabel().count(from: "down 11.0 up 7", to: "down 5.0 up 11", interval: 0.2)
For those who likes to play with strings format. Is it as well awaiable to modife for each number format passing it in array.
Remember the format array have to be the sime element count as the shortest strings from
or to
number count. And the format need to be specify for float values which means "%f"
, ex:"%.2f"
or "%0.2f %%"
or any custom format you wont to add.
UILabel().count(from: "down 11.0 up 7", to: "down 5.0 up 11", format: ["%0.2f", "%0.0f"])
Full example:
UILabel().count(from: "down 11.0 up 7", to: "down 5.0 up 11", interval: 0.2, format: ["%0.2f", "%0.0f"])
CocoaPods:
Add the line pod "SCountLabel"
to your Podfile
Carthage:
Add the line github "shial4/SCountLabel"
to your Cartfile
Manual:
Clone the repo and drag the file SCountLabel.swift
into your Xcode project.
Swift Package Manager:
Add the line .Package(url: "https://github.com/shial4/SCountLabel.git", majorVersion: 0, minor: 0)
to your Package.swift
Be welcome to contribute to this project! :)
Just create an issue on GitHub.
This project was released under the MIT license.