【问题标题】:Swift: Change the Label text while progress view is complete 1.0Swift:在进度视图完成时更改标签文本 1.0
【发布时间】:2019-01-08 07:33:42
【问题描述】:

我有一个带有标签的progressView。当页面加载时,进度条会以 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)`

当我的进度视图完成其过程或它的值变为 1.0 时,我希望将标签文本从“等一下”更改为“手动输入 OTP”。

【问题讨论】:

    标签: swift xcode uilabel progress-bar uiprogressview


    【解决方案1】:

    当前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"
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多