A countdown button for swift

WWCountdownButton

A countdown button.
一個倒數計時的按鈕.

Installation with Swift Package Manager

dependencies: [
    .package(url: "https://github.com/William-Weng/WWCountdownButton.git", .upToNextMajor(from: "1.0.0"))
]

Example

import UIKit
import WWCountdownButton
import WWPrint

final class ViewController: UIViewController {

    override func viewDidLoad() { super.viewDidLoad() }
    
    @IBAction func countdown1(_ sender: WWCountdownButton) { sender.countdown(second: 120) }
    
    @IBAction func countdown2(_ sender: WWCountdownButton) { sender.countdown(second: 60, isCountdown: false) }
    
    @IBAction func countdown3(_ sender: WWCountdownButton) {
        
        sender.countdown(second: 5) { info in
            if (info.isFinish) { sender.backgroundColor = .darkGray }
            wwPrint(info)
        }
    }
}

GitHub

View Github