suzuki-0000 / CountdownLabel

Simple countdown UILabel with morphing animation, and some useful function.
MIT License
999 stars 192 forks source link

Is it possible to count up instead of down? #42

Open roundfly opened 5 years ago

roundfly commented 5 years ago

Not really an issue so close this but was just wondering wether it's possible to count upwards instead of down, given a value of say 30 minutes but starting from 0 then going to 30? None of the public API method's seem to be able to point me in the right direction regarding this. Also props on this framework, +star from me.

AmirMehr commented 5 years ago

I handle it as follow: I set a time interval that call add function every 1 second, it will automatically animate

`

            // 0 is the start time to increase
            let time: TimeInterval = TimeInterval(0)

            orderCountDown.setCountDownTime(minutes: time)

            orderCountDown.timeFormat = "mm:ss"

            orderCountDown.animationType = .Evaporate

            // set a time interval to repeat every second and add time to it
            // it will automatically animate
                Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(CurrentOrderCell.addTime), userInfo: nil, repeats: true)

            @objc func addTime(){

                    order.remainSeconds += 1

                    let time: TimeInterval = TimeInterval(order.remainSeconds)

                    orderCountDown.setCountDownTime(minutes: time)

                }

            `