2

I have a progressView with the label. when the page is loaded progress bar is started wit the value 0.0 and upto 1.0. This is my progressView code.

Function

@objc func updateProgress() {
        progressValue = progressValue + 0.01
        self.progressView.progress = Float(progressValue)

        if progressValue != 1.0 {
            progressView.isHidden = false
            self.perform(#selector(updateProgress), with: nil, afterDelay: 0.2)
        }
    }

Call The function in ViewDidLoad ad below.

self.perform(#selector(updateProgress), with: nil, afterDelay: 0.2)`

I want the change the label text from "Wait a while" to "Enter OTP Manually" when my progress view is complete its process or it's Value is become 1.0.

Krunal Nagvadia
  • 1,083
  • 2
  • 12
  • 33

1 Answers1

3

Current if-statement looks fine but i would go with this to avoid any float rounding issue,

    if progressValue < 1.0 { // Considering 1.0 is the max value.
        progressView.isHidden = false
        self.perform(#selector(updateProgress), with: nil, afterDelay: 0.2)
    } else {
       self.label.text = "Enter OTP Manually"
    }
Kamran
  • 14,987
  • 4
  • 33
  • 51