Swift:在进度 View 完成时更改标签文本 1.0

标签 swift xcode uilabel progress-bar uiprogressview

我有一个带有标签的进度 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/

相关文章:

iphone - 在未完成的方法内运行方法

ios - 在从 XIB 加载的自定义 View 中修改 UIButton 的标题标签

ios - 如何强制 UILabel 更新其文本?

ios - 如何从 tableView : cellForRowAtIndexPath: using `indexPath` argument? 中获取索引号

ios - 快速叠加两个视频

ios - UIDatePicker 在滚动完成后产生反馈。需要解释

ios - 如何处理从另一个应用程序发送到我自己的 iOS 应用程序的 'Open in...' 文件?

iphone - 获取 Google map 的静态图像

ios - 在属性字符串上设置 NSForegroundColorAttributeName 会在 iOS 6 上向下移动文本

ios - 在运行时 iOS 应用程序中下载程序文件