问题描述
花了我几天的时间来寻找这个问题的根源。
我有一个带有自定义表格单元格行的TableView,每个表格单元格内都有一个进度视图。该应用程序要求进度视图的色调基于填充的程度为绿色/琥珀色/红色。
我发现以编程方式设置progressTint会使进度条显得比应有的更饱满。
相关代码(tableView cellForRowAt):
let Max:Double = MyGroup!.EndTimeSeconds - MyGroup!.StartTimeSeconds //10771
let Progress:Double = Date().timeIntervalSince1970 - MyGroup!.StartTimeSeconds //1599.7007069587708
if (Max >= Progress) {
Cell.DescriptionLabel.textColor = UIColor.black
Cell.SubtitleLabel.textColor = UIColor.black
Cell.TargetDeliveryTimeLabel.textColor = UIColor.pts_darkergrey
Cell.ProgressView.setProgress(Float(Progress / Max),animated: false)
Cell.ProgressView.progress = Float(Progress / Max)
Cell.ProgressView.progressTintColor = UIColor.pts_green //if i comment these out it works.
if (Max * 0.75 <= Progress) {
Cell.ProgressView.progressTintColor = UIColor.pts_pbamber //if i comment these out it works.
}
} else {
Cell.DescriptionLabel.textColor = UIColor.white
Cell.SubtitleLabel.textColor = UIColor.white
Cell.TargetDeliveryTimeLabel.textColor = UIColor.white
Cell.ProgressView.setProgress(1,animated: false)
Cell.ProgressView.progress = 1
Cell.ProgressView.progressTintColor = UIColor.pts_pbred //if i comment these out it works.
}
Cell.ProgressView.layer.cornerRadius = 4
Cell.ProgressView.clipsToBounds = true
已注释掉progressTint呼叫的屏幕截图:
具有progressTint调用有效的屏幕截图:
请注意,设置色调后,第二项的进度条会错误地填充到几乎50%。
进度条应随时间线性填充-但是它将保持静止,直到进度合法地超过此点,然后像往常一样继续进行。
我可能正在看东西,但问题似乎会持续影响前两个项目,而不会影响其余的项目(或多或少)
我已经尝试了ProgressView.progress和ProgressView.setProgress以及ProgressView.progressTintColor和PogressView.tintColor。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)