I want to update gauge value with timer with smooth animation, currently the value is updated using Timer but the animation is not smooth, showing jerky animation. Is there any property like "gaugeView.setGaugeValue" instead "gaugeView.gaugeValue"?
Here is my code:
var timer = Timer()
var speedTime : Int = 0
{
didSet
{
DispatchQueue.main.async {
self.gaugeView.gaugeValue = CGFloat(CGFloat(self.speedTime))
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
setupGaugeView()
timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(self.updateTimer), userInfo: nil, repeats: true)
}
@objc func updateTimer() {
if speedTime >= 80 {
timer.invalidate()
} else {
speedTime += 1
}
}
Please help me and provide any solution for this.
Thank you in advance.
I want to update gauge value with timer with smooth animation, currently the value is updated using Timer but the animation is not smooth, showing jerky animation. Is there any property like "gaugeView.setGaugeValue" instead "gaugeView.gaugeValue"?
Here is my code:
Please help me and provide any solution for this. Thank you in advance.