I want to make an Activity Indicator start animating and then stop after one second.
So does anyone know how I could do that?
class stuff {
@IBOutlet
Here is a cleaner and more expressive code to do this using Swift 3.1 and Grand Central Dispatch:
Swift 3.1:
indicator.startAnimating()
// Runs after 1 second on the main queue.
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1) ) {
indicator.stopAnimating()
}
Also .seconds(Int), .microseconds(Int) and .nanoseconds(Int) may be used for the time.