luispadron / UICircularProgressRing

A circular progress bar for iOS written in Swift
MIT License
1.73k stars 290 forks source link

Setting a UICircularProgressRing value before running it isn't working #235

Closed joeljfischer closed 4 years ago

joeljfischer commented 4 years ago

Bug Report

I'm attempting to set an initial value to the UICircularProgressRing before running it from that value to the end, however, it doesn't seem to be working correctly.

Version

v6.5.0

Overview of what you tried to do

I have tried several things, from pausing the timer to resetting the timer. Sometimes this resulted in the progress ring appearing completed, and sometimes it resulted in it not running at all. I expected it to start at the initially provided value above the minValue and continuing to the given to value.

Post sample code or example here

        timerRingView.resetProgress()
        timerRingView.maxValue = 35.0
        timerRingView.value = 22.78
        timerRingView.startProgress(to: 35.0, duration: 12.22)

This particular version of the code results in the progress ring appearing fully completed.

Have you tried fixing this yourself?

I attempted modifying the startProgress function as so:

public func startProgress(to value: CGFloat, duration: TimeInterval, completion: ProgressCompletion? = nil) {
        // Store the completion event locally
        self.completion = completion

        // call super class helper function to begin animating layer
        startAnimation(duration: duration) {
            self.value = value
            self.delegate?.didFinishProgress(for: self)
            self.completion?()
        }
    }

This did not work, it shows the progress ring at the correct value (the value set before startProgress, but no animation runs to the to value.

luispadron commented 4 years ago

Hey there, have you tried:

        timerRingView.resetProgress()
        timerRingView.maxValue = 35.0
        timerRingView.startProgress(to: 22.78, duration: 0)
        timerRingView.startProgress(to: 35.0, duration: 12.22)
luispadron commented 4 years ago

You can also take a look at #222 and my comment at the end

joeljfischer commented 4 years ago

The first comment didn't work, the second seems to be working as I want it to! Thanks for the help :)