I want my Progress Bar to update every milliseconds. How would I do this? Currently, it updates every second, which is not what I want.
EDIT: Sorry, I forgot to mention that I still want the timer label to update every second (So it will go down by seconds not milliseconds: 10, 9, 8) while updating the progress bar every milliseconds or 25 times every second.
Code:
progressBar.transform = progressBar.transform.scaledBy(x: 1, y: 5)
progressBar.layer.cornerRadius = 5
progressBar.clipsToBounds = true
progressBar.layer.sublayers![1].cornerRadius = 5
progressBar.subviews[1].clipsToBounds = true
func startTimer() {
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(timerUpdate), userInfo: nil, repeats: true)
}
@objc func timerUpdate() {
if timeRemaining <= 0 {
progressBar.setProgress(Float(0), animated: false)
bonusTimerLabel.text = "0"
bonusTimerLabel.textColor = UIColor(red: 186/255, green: 16/255, blue: 16/255, alpha: 1)
} else {
progressBar.setProgress(Float(timeRemaining)/Float(10), animated: false)
timeRemaining -= 1
bonusTimerLabel.text = "\(timeRemaining)"
}