UIProgressView在较小的值上更新不佳

时间:2019-03-10 18:55:30

标签: ios objective-c swift cocoa-touch uiprogressview

我正在迭代更新UIProgressView。值从0.0开始并增加到1.0。

有2个问题:

  1. 动画效果很好(注意逐步更新和延迟):

enter image description here

  1. 设置为0时,进度视图不会显示为空。这是i == 0.0时栏的外观:

enter image description here

这是我在操场上运行的代码:

import UIKit

let progressView = UIProgressView(frame: CGRect(origin: .zero, size: CGSize(width: 100, height: 100)))
progressView.trackTintColor = .white
progressView.progressTintColor = .black
progressView.layer.cornerRadius = 2.5
progressView.clipsToBounds = true

var i: Float = 0.0
while i <= 1.0 {
  i += 0.0001
  progressView.progress = i
}

问题是:

  1. 为什么将进度条设置为0.0时,进度条不会空白?为什么要等到0.05左右然后“跳”?

  2. 为什么更新Flakey? (animated设置为true)。

0 个答案:

没有答案