/BT-Timer

An off-the-shelf timer/stopwatch to use in your iOS apps

Primary LanguageSwiftMIT LicenseMIT

BT-Timer

Version License Platform

Timer

Stopwatch

Timer

Setup

1- Initialize BTtimer specifying...

  • The label it should be linked to.
  • The time it should countdown.
  • whether the label should be animating or not.
  let timer:BTtimer!
  override func viewDidLoad() {
      ...
      timer = BTtimer(for: label, withTimeInSecs: 1 * 60 * 60, animate: true)
  }

2- Control the timer

  timer.fire()
  timer.pause()
  timer.stop()
  timer.reset()

3- Implement BTtimerDelegate with the available functions...

extension UIViewController : BTtimerDelegate {
    public func didStart() { }
    
    public func didTick(with secondsLeft: Int) { }
    
    public func didTimeOutWhileInBackground(since secondsPassed: Int) { }
    
    public func didTimeOut() { }
}

Stopwatch

Setup

1- Initialize BTstopwatch specifying...

  • The label it should be linked to.
  • whether the label should be animating or not.
  stopwatch:BTstopwatch!
  override func viewDidLoad() {
      ...
      stopwatch = BTstopwatch(for: label, animated: true)
  }

2- Control the timer

  stopwatch.fire()
  stopwatch.pause()
  stopwatch.stop()
  stopwatch.restart()

3- Implement StopwatchDelegate with the available functions...

extension UIViewController : StopwatchDelegate {
    public func stopwatchWasInterrupted(at timePassedInSec:Int) { }
}

Installation

BT-Timer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'BT-Timer'

Author

Omar Labib, o.labib1995@gmail.com

License

BT-Timer is available under the MIT license. See the LICENSE file for more info.