skip to Main Content

In iOS15 UIProgressView changed behavior. When I use self.progress.setProgress(1.0, animated: true), it starts from transparent style. How to return to "alpha = 1" style.

  1. progress = 0

  2. progress = 20%

  3. progress = 70%

  4. progress = 90%

P.S.: progress.alpha = 1 does not work

2

Answers


  1. Chosen as BEST ANSWER

    The only way to change this opaque/transparent behavior is to use your own Timer.

    private let progressUnit = Progress(totalUnitCount: 20)
    
    func startAnimate(){
            self.progressView.setProgress(0.0, animated: false)
            self.progressUnit.completedUnitCount = 0
            
            Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { timer in
                guard self.progressUnit.isFinished == false else{
                    timer.invalidate()
                    return
                }
                
                self.progressUnit.completedUnitCount += 1
                let progressFloat = Float(self.progressUnit.fractionCompleted)
                self.progressView.setProgress(progressFloat, animated: true)
            }
        }
    

  2. properties
    progressImage and trackImage it worked fine as on previous iOS versions

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search