maxkonovalov / MKRingProgressView

⭕️ Ring progress view similar to Activity app on Apple Watch
MIT License
1.57k stars 136 forks source link

Animation not working #56

Closed harish-kamath closed 4 years ago

harish-kamath commented 5 years ago

I currently have the progress view in a table view cell. The progress value sets correctly, but there is no animation, despite using UIView.animate. Other animations work fine. It seems that upon reloading the cell, animation works correctly.

mgrider commented 5 years ago

UIView progress animation isn't working for me either, in a brand new single-view project. Example code is essentially straight out of the README, and plopped into viewDidAppear. I don't know if I'm just missing something dumb, but the ring just appears completed immediately. Strangely, if I set a completed block, that will run when the animation should have finished.

ivankholod commented 5 years ago

Same issues for me. No animation.

SharpZKing commented 4 years ago

I currently have the progress view in a table view cell. The progress value sets correctly, but there is no animation, despite using UIView.animate. Other animations work fine. It seems that upon reloading the cell, animation works correctly.

UIView.animate..... not work for me too, but you can try like this:

extension RingProgressView {
    func animateTo(_ number : Int) {
        let now = DispatchTime.now()
        for index in 0...number {
            let milliseconds = 10 * index
            let deadline: DispatchTime = now + .milliseconds(milliseconds)
            DispatchQueue.main.asyncAfter(deadline: deadline) {
                self.progress = Double(index)/100
            }
        }
    }
}
maxkonovalov commented 4 years ago

Just checked on the ProgressRingExample project - animation works without any issues with the following code:

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        UIView.animate(withDuration: 1.0) {
            self.ringProgressView.progress = 0.5
        }
    }

Maybe there are some additional changes in your code that affect the animations?

xaphod commented 4 years ago

Happening to me too. Still looking into it, but on line 115 of RingProgressLayer, presentation()?.value(forKey: event) = nil, which I don't expect is correct

xaphod commented 4 years ago

Deleted my last comment, sorry -- I posted PR #71 with a potential fix (works for me)

maxkonovalov commented 4 years ago

Hey guys, I pushed a small modification of a fix (#71) provided by @xaphod. I tried it on a table view setup and it worked for me. Please let me know if there are still any issues.

zeinrezky commented 3 years ago

Hi @maxkonovalov , does the progress can take negative value?

maxkonovalov commented 3 years ago

@zeinrezky negative values are not supported, but if you need anti-clockwise direction, you can use it like this: progressView.transform = CGAffineTransform(scaleX: -1, y: 1)