I have created UIProgressView
and UILabel
programatically. I want my progressbar to get update every second and show the progress on screen and also update the label value. All of this should done on the call of viewDidLoad()
.
Take a variable of type Timer?
, then simply start your timer from your viewDidLoad
method which will receive call after every one second.
Then simply update your progressBar.progress
and label.text
value in that method as mentioned below:
Take a variable
var timer:Timer?
In your viewDidLoad
use
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector:#selector(self.updateProgressAndLabelValue), userInfo: nil, repeats: true)
Make a function and do the needful
func updateProgressAndLabelValue(){
//You will get call every second here
//You can update the progressBar and Label here only
//For example: yourProgressViewOutlet.progress = updatedValue
//And lblYOuLabel.text = "\(updatedValue)"
}