我有一个带有标签的进度 View 。当页面加载时,进度条开始显示值 0.0 到 1.0。这是我的 ProgressView 代码。
功能
@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)
}
}
调用下面ViewDidLoad广告中的函数。
self.perform(#selector(updateProgress), with: nil, afterDelay: 0.2)`
当我的进度 View 完成其过程或它的值变为 1.0 时,我希望将标签文本从“稍等片刻”更改为“手动输入 OTP”。
最佳答案
当前的 if-statement
看起来不错,但我会使用它以避免任何 float
舍入问题,
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"
}
关于Swift:在进度 View 完成时更改标签文本 1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54087121/