2017-08-11 10 views
0

私は80(min)〜475(max)の間で連続的に値を変更するUIViewにラベルを保持していますので、ラベルの最大値と最小値を連続して実行しました。私が今までに試したコードのどこにあるか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の値を増減できましたが、それを解決できませんでした。ラベルのmax min値に関してプログレスバーの正確な増減値を計算する方法に関する情報が必要です。

+0

だけアドバイスが、* *、あなたの将来の同僚のために、このようなあなたのコードをフォーマットしないでください。 – the4kman

答えて

1

試してみてください。

v = (ampsMaxValue - 80)/(475 - 80) 
+0

ありがとうございましたYun、That作品 –

関連する問題