0
我在我的UIView中有標籤,它連續地在80(分鐘)到475(最大值)之間改變數值,現在我已經對標籤的最大和最小值連續運行進度條狀態。下面代碼我已經試過,直到現在iOS進度條自定義最大值和最小值
if ampsMaxValue <= 80
{
ampsMaxValue = 80
ampsLabel.text = String(ampsMaxValue)
ampsprogressBar.progress = Float(0)
return
}
ampsMaxValue = ampsMaxValue - 1
ampsLabel.textColor = UIColor.white
ampsprogressBar.tintColor = UIColor.red
ampsLabel.text = String(ampsMaxValue)
v -= 0.1
ampsprogressBar.progress = Float(v)
}else{
if ampsMaxValue >= 475
{
ampsMaxValue = 475
ampsLabel.text = String(ampsMaxValue)
ampsprogressBar.progress = Float(1)
return;
}
ampsMaxValue = ampsMaxValue + 1
ampsLabel.textColor = UIColor.white
ampsprogressBar.tintColor = UIColor.red
ampsLabel.text = String(ampsMaxValue)
v += 0.1
ampsprogressBar.progress = Float(v)
}
我能夠顯示0.1增加和減少值,但沒有解決它。需要關於如何計算進度條相對於標籤最大值和最小值的準確增加值和減少值的信息。
只是一個建議,但*請*,爲你的未來同事的份上,不要格式化你這樣的代碼。 – the4kman