I am trying to animate a UILabel to go from 0% to (insert number)%, and show each number in between in a duration of 1 second..
I have failed until now and I am going crazy :-)
I haven't even made it to the part where I can set the duration yet.. What I have done so far (and failed at) is this:
var current: Int = Int(0.0 * 100)
let endValue: Int = Int(toValue * 100)
if current < endValue {
self.progressLabel.text = "\(current)%"
current += Int(0.01 * 100)
}
The toValue
is a Double that it is receiving when the function is called.
Any help would be great!
EDIT:
I made it show the correct endValue
in the uilabel using this code instead and moving var current...
up before the viewDidLoad. The problem is now that it is not showing the numbers in between the current and the endValue in the progressLabel.text
..
while current <= endValue {
self.progressLabel.text = "\(current)%"
current = current + Int(0.01 * 100)
}