{"id":2579,"url":"https://github.com/suzuki-0000/CountdownLabel","last_synced_at":"2025-08-06T16:30:53.772Z","repository":{"id":3545592,"uuid":"49942729","full_name":"suzuki-0000/CountdownLabel","owner":"suzuki-0000","description":"Simple countdown UILabel with morphing animation, and some useful function.","archived":false,"fork":false,"pushed_at":"2022-03-07T04:03:30.000Z","size":4162,"stargazers_count":1006,"open_issues_count":35,"forks_count":192,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-12-08T00:03:31.443Z","etag":null,"topics":["countdown","swift","timer"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suzuki-0000.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-19T09:48:36.000Z","updated_at":"2024-12-02T08:20:14.000Z","dependencies_parsed_at":"2022-11-28T10:33:55.592Z","dependency_job_id":null,"html_url":"https://github.com/suzuki-0000/CountdownLabel","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-0000%2FCountdownLabel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-0000%2FCountdownLabel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-0000%2FCountdownLabel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suzuki-0000%2FCountdownLabel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suzuki-0000","download_url":"https://codeload.github.com/suzuki-0000/CountdownLabel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923688,"owners_count":17992566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["countdown","swift","timer"],"created_at":"2024-01-05T20:16:17.418Z","updated_at":"2024-12-09T16:31:01.261Z","avatar_url":"https://github.com/suzuki-0000.png","language":"Swift","funding_links":[],"categories":["UI","Libs","TextField","UI [🔝](#readme)","Content"],"sub_categories":["Label","UI","Other free courses"],"readme":"CountdownLabel\n========================\n\n![Swift](http://img.shields.io/badge/swift-4.0-brightgreen.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CountdownLabel.svg?style=flat)](http://cocoadocs.org/docsets/CountdownLabel)\n\nSimple countdown UILabel with morphing animation, and some useful function.\n\n![sample](Screenshots/example01.gif)\n\n## features\n- Simple creation\n- Easily get status of countdown from property and delegate.\n- Insert some of function, and completion\n- Style change as usual as UILabel do\n- Morphing animation from [LTMorphingLabel](https://github.com/lexrus/LTMorphingLabel).\n- XCTest assertion\n\n### Version vs Swift version.\n\nBelow is a table that shows which version of what you should use for your Swift version.\n\n| Swift version | version    |\n| ------------- | --------------- |\n| 4.2           | \u003e= 4.0 |\n| 4.0, 4.1      | \u003e= 3.0 |\n| 3.X           | \u003e= 2.0 |\n| 2.3           | 1.3  |\n\n## Usage\nYou need only 2 lines. \n\n```swift\n// from current Date, after 30 minutes.\nlet countdownLabel = CountdownLabel(frame: frame, minutes: 30) // you can use NSDate as well\ncountdownLabel.start()\n```\n\n#### Morphing example\nUse `animationType`.\nThose effect comes from [LTMorphingLabel](https://github.com/lexrus/LTMorphingLabel).\n\n```swift\nlet countdownLabel = CountdownLabel(frame: CGRectZero, time: 60*60)\ncountdownLabel.animationType = .Pixelate\ncountdownLabel.start()\n```\n\n| morphing effect | example | \n| -------- |--------- | \n| .Burn |  ![sample](Screenshots/exampleBurn.gif) |\n| .Evaporate |  ![sample](Screenshots/exampleEvaporate.gif) |\n| .Fall |  ![sample](Screenshots/exampleFall.gif) |\n| .Pixelate | ![sample](Screenshots/examplePixelate.gif) |   \n| .Scale | ![sample](Screenshots/exampleScale.gif) |   \n| .Sparkle | ![sample](Screenshots/exampleSparkle.gif) |\n\n#### Style\nyou can directly allocate it as a UILabel property just like usual.\n\n```swift\ncountdownLabel.textColor = .orangeColor()\ncountdownLabel.font = UIFont(name:\"Courier\", size:UIFont.labelFontSize())\ncountdownLabel.start()\n```\n\n![sample](Screenshots/example02.gif) \n\n#### Get Status of timer\nthere's some property for reading status.\n```swift\ncountdownLabel.timeCounted      // timer that has been counted\ncountdownLabel.timeRemaining    // timer's remaining\n\n// example\n@IBAction func getTimerCounted(sender: UIButton) {\n    debugPrint(\"\\(countdownLabel.timeCounted)\")\n}\n\n@IBAction func getTimerRemain(sender: UIButton) {\n    debugPrint(\"\\(countdownLabel.timeRemaining)\")\n}\n```\n\n![sample](Screenshots/example03.gif) \n\n#### Control countdown\nYou can pause, start, change time.\n\n```swift\n// check if pause or not\nif countdownLabel.isPaused {\n    // timer start\n    countdownLabel.start()\n} else {\n    // timer pause\n    countdownLabel.pause()\n}\n```\n\n```swift\n// -2 minutes for ending\n@IBAction func minus(btn: UIButton) {\n    countdownLabel.addTime(-2)\n}\n    \n// +2 minutes for ending\n@IBAction func plus(btn: UIButton) {\n    countdownLabel.addTime(2)\n}\n```\n\n![sample](Screenshots/example04.gif) \n\n#### Insert Function\nUsing `then` function or `delegate`, you can set your function anywhere you like.\n\n```swift\n// then property \ncountdownLabel.then(10) { [unowned self] in\n    self.countdownLabel.animationType = .Pixelate\n    self.countdownLabel.textColor = .greenColor()\n}\ncountdownLabel.then(5) { [unowned self] in\n    self.countdownLabel.animationType = .Sparkle\n    self.countdownLabel.textColor = .yellowColor()\n}\ncountdownLabel.start() {\n    self.countdownLabel.textColor = .whiteColor()\n}\n\n// delegate\nfunc countingAt(timeCounted timeCounted: NSTimeInterval, timeRemaining: NSTimeInterval) {\n    switch timeRemaining {\n    case 10:\n        self.countdownLabel6.animationType = .Pixelate\n        self.countdownLabel6.textColor = .greenColor()\n    case 5:\n        self.countdownLabel6.animationType = .Sparkle\n        self.countdownLabel6.textColor = .yellowColor()\n    default:\n        break\n    }\n}\nfunc countdownFinished() {\n    self.countdownLabel.textColor = .whiteColor()\n}\n\n```\n\n![sample](Screenshots/example06.gif) \n\n#### Attributed Text\nyou can set as attributedText too. note:but morphing animation will be disabled.\n```swift\ncountdownLabel.setCountDownTime(30)\ncountdownLabel.timeFormat = \"ss\"\ncountdownLabel.countdownAttributedText = CountdownAttributedText(text: \"timer HERE in text\", replacement: \"HERE\")\ncountdownLabel.start() \n```\n\n![sample](Screenshots/example07.gif) \n\n\n#### Format\nDon't specified over 24 hours or you'll get wrong format.\nCountdownLabel uses `00:00:00 (HH:mm:ss)` as default format.\nif you prefer using another format, Your can set your time format like below.\n\n\n`countdownLabel.timeFormat = @\"mm:ss\"`\n\n\n#### Scheduled\nyou can set scheduled timer\n\n```swift\n// after 10 minutes will start a countdown from 20.\nlet fromDate   = NSDate().dateByAddingTimeInterval(10)\nlet targetDate = fromDate.dateByAddingTimeInterval(20)\nlet countdownLabel = CountdownLabel(frame: CGRectZero, fromDate: fromDate, targetDate: targetDate)\ncountdownLabel.start()\n```\n\n#### Check Status \nsome public properties are useful. \n\n```swift\ncountdownLabel.isCounting      // check timer is counting now\ncountdownLabel.isPaused        // check timer was stopped\ncountdownLabel.isFinished      // check timer has ended\ncountdownLabel.morphingEnabled // check morphing is enabled\n```\n\n## Requirements\n- iOS 9.0+\n- Swift 2.3+\n- ARC\n\n##Installation\n\n####CocoaPods\navailable on CocoaPods. Just add the following to your project Podfile:\n```\npod 'CountdownLabel'\nuse_frameworks!\n```\n\n####Carthage\nTo integrate into your Xcode project using Carthage, specify it in your Cartfile:\n\n```ogdl\ngithub \"suzuki-0000/CountdownLabel\"\n```\n\n## Inspirations\n* [LTMorphingLabel](https://github.com/lexrus/LTMorphingLabel) is motivation for creating this.\n* In many reference from [MZTimerLabel](https://github.com/mineschan/MZTimerLabel).  \n\n## License\navailable under the MIT license. See the LICENSE file for more info.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuzuki-0000%2FCountdownLabel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuzuki-0000%2FCountdownLabel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuzuki-0000%2FCountdownLabel/lists"}