TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2016 |
SPMSupports SPM | ✗ |
Maintained by Martin Kluska.
To run the example project, clone the repo, and run pod install
from the Example directory first.
CountDownLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "CountDownLabel"
Martin Kluska, [email protected]
CountDownLabel is available under the MIT license. See the LICENSE file for more info.
Import the module
import CountDownTimeAgoLabel
When the date is set to label/countdown objects, the timer will start (if the formatter is set). You can create CountDown
object for a custom UI or you can create a CountDownLabel
with automatic text updating
Via own delegate
let countDown = CountDown(aDelegate: self)
countDown.date = NSDate(...)
...
func countDownChanged(countDown: CountDown, format: String) {
testLabel.text = format
}
Via label (code)
let label = CountDownLabel(frame: CGRectZero)
...
label = NSDate(...)
Manualy start the timer
let countDown = CountDown(aDelegate: self)
countDown.autoStartOnDate = false
countDown.date = NSDate(...)
countDown.start()
...
countDown.stop()
In default uses the CountDownBaseFormatter with custom styles for date or time.
You can set it by accessing the formatter object.
let formatter = countDown.formatter as? CountDownBaseFormater
formatter?.dateStyle = .Full // this value is default
formatter?.timeStyle = .Full // this value is default
CountDownFormatStyle
Renders the part of date/time in given style
You can set the logic how the label is rendered by setting the countDown.logic
CountDownLogic
Drag a UILabel to your view and set the class to CountDownLabel
. In your attributes tab you can change the
settings for the label. This will change the countdowns properties.
You can access the labels CountDown object via label.countDown
.
You can set:
You can call:
You can set:
You can call:
All UILabel methods, also you can access to the countDown instance via label.countDown
You can create a custom style logic for the base formatter (CountDownBaseFormatter
) by using CountDownStyleProtocol
or you can create your own formatter via protocol CountDownFormatProtocol
Are welcome :)