TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | echo "4.0" > .swift-version` |
SPMSupports SPM | ✗ |
Maintained by BRCountDownView.
BORING Countdown animated - customizable UI Components.
This is customizable UI-View components to countdown given seconds with countdown animations.
Many properties can be customized including count-down animation by your own!
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 9.0 +
Swift 3.0 +
BRCountDownView is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod 'BRCountDownView'
Since this is straightforwardly simple to use, you can get how to use BRCountDownView by chekcing ViewController.swift in example project.
Step 1. create BRCountDownView programmatically or via storyboard or xib.
By doing so, You can not only create BRCountDown instance, but also customize properties including countdown animation on your own way.
Check sample code below.
Below is how to create BRCountDownView programmatically.
(programmatically creating BRCountDownView is highly preffered.)
lazy var countdownView: BRCountDownView = {
let countdownView = BRCountDownView(timeSeconds: /* 30000 */ 5)
countdownView.animationStyle = .slideInFromBottom
/** you can make animate that you would like to perform in this closure if you would.
To do this, you should change animationStyle property to 'true'.
*/
// countdownView.animationStyle = .custom
// countdownView.customAnimation = {
// [unowned self] animateView, duration in
// UIView.animate(withDuration: duration, animations: {
// animateView.alpha = 0.0
// }, completion:{ finished in
// if finished {
// animateView.alpha = 1.0
// }
// })
// }
countdownView.didFinish = {
[unowned self] (countdownView) -> Void in
DispatchQueue.main.async {
self.checkTestLabel.text = "countdown is finished..."
}
/** you can again repeat countdown with seconds you want whenever you want. */
// self.countdownView.repeatCountDown(in: 5)
}
countdownView.didRepeat = {
[unowned self] (countdownView) -> Void in
// it is fired when count-down repeat gets started.
DispatchQueue.main.async {
self.checkTestLabel.text = "countdown is repeated..."
}
}
countdownView.didResume = {
[unowned self] (countdownView) -> Void in
/**
do any task here if you need.
*/
print("didResume!")
}
countdownView.didTerminate = {
[unowned self] (countdownView) -> Void in
/**
do any task here if you need.
*/
print("didTerminate!")
}
countdownView.didStop = {
[unowned self] (countdownView) -> Void in
/**
do any task here if you need.
*/
print("didStop!")
}
countdownView.isUserInteractionEnabled = true
countdownView.didTouchBegin = {
[unowned self] sender in
print("didTouchBegin!?")
}
countdownView.didTouchEnd = {
[unowned self] sender in
print("didTouchEnd!?")
}
return countdownView
}()
Step2. add BRCountDownView instance that programmatically created on a view hierachy that you need.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.view.addSubview(countdownView)
// get center.
countdownView.center = CGPoint(x: self.view.frame.size.width / 2,
y: self.view.frame.size.height / 2)
}
Jang seoksoon, [email protected]
BRCountDownView is available under the MIT license. See the LICENSE file for more info.