In my app I need to display a "Loading" text in an UILabel, repeatedly as follows:
Loading Loading. Loading.. Loading... Loading Loading. Loading.. Loading...
How can I do it? Any suggestion, please?
Swift 4.2
You can simply use Timer.
var timer: Timer?
titleLabel.text = "Loading ."
timer = Timer.scheduledTimer(withTimeInterval: 0.55, repeats: true) { (timer) in
var string: String {
switch self.titleLabel.text {
case "Loading .": return "Loading .."
case "Loading ..": return "Loading ..."
case "Loading ...": return "Loading ."
default: return "Loading"
}
}
self.titleLabel.text = string
}
// Stop the timer
// timer?.invalidate()
Result

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With