Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
CountableLabel
is a UILabel
that was heavily inspired by GCountableUILabel. This subclass will provided a variety of nice text setting animations especially when the label is used for dynamic number changes. The reason we built our own version of GCountableUILabel
is because the original repo was written in Objective-C
, on top of that decrementing/setting of different size text cause a lot of breaking in the pod. With the new version you are free to change the text to what ever you choose! Happy Counting!
Contents
Features
- Works with all devices running iOS 9+.
- Override
text
internally to keep the usage extremely simple. - 3 types of animations (PushUp, PushDown, Fade) and a feature have no animation as well.
- Works with autolayout, honors intrinsic sizing, and self sizes on the fly.
- Works with labels created in code and in Interface Builder.
- Example app with lots of real-time configurations that lets you dynamically increment/decrement a value of your choosing, specify which animation you want to use, and specify text alignment of the label!
Usage
Set up
Swap any UILabel
with CountableLabel
:
In code
Before:
class ViewController {
let label = UILabel()
}
After:
import CountableLabel
class ViewController {
let label = CountableLabel()
}
In Interface Builder
Before:
After:
Animation Type
Set label.animationType = .pushUp
to see text go bottom up across the label.
Set label.animationType = .pushDown
to see text go top down across the label.
Set label.animationType = .fade
to see text fade in and out on the label.
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects.
CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:
$ gem install cocoapods
To integrate CountableLabel
into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'CountableLabel'
Then, run the following command:
$ pod install
In case Xcode complains ("Cannot load underlying module for CountableLabel") go to Product and choose Clean (or simply press ⇧⌘K).
Manually
If you prefer not to use CocoaPods, you can integrate CountableLabel
into your project manually.
License
CountableLabel
is developed by Andrew Foghel at StockX and is released under the MIT license. See the LICENSE
file for details.
Contact
Feel free to email me (at andrewfoghel@gmail.com). If you find any problems with the project or have ideas to enhance it, feel free to open a GitHub issue and/or create a pull request.