luispadron / UICircularProgressRing

A circular progress bar for iOS written in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UICircularProgressRing does not animate

johnrajahkkd opened this issue · comments

Hi,

I have added the UICircularProgressRing programmatically,
Also, I have set min and max value for the and start the progress. But it does not animates.

Here is my code,

class ViewController: UIViewController {
    
    lazy var progressRing: UICircularProgressRing = { [unowned self] in
       let ring = UICircularProgressRing(frame: CGRect(x: 150, y: 300, width: 125, height: 125))
        ring.minValue = 0
        ring.maxValue = 100        
        return ring
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.addSubview(progressRing)
        progressRing.startProgress(to: 100, duration: 4.0)
        
    }

}

Can anyone tell what's the issue here? Thanks!

You need to move the animation code to viewDidAppear instead of viewDidLoad

As @MobileMon mentions animation needs to be done after the view appears.