Delay Actions in Swift

后端 未结 4 597
长情又很酷
长情又很酷 2020-12-24 11:58

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         


        
4条回答
  •  太阳男子
    2020-12-24 12:46

    New in iOS 10, Timer has a block initializer that executes on the main thread. Its also slightly more flexible because you can take a reference to the Timer and cancel it or reschedule it after the fact.

        let timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: false) {_ in 
        }
    

提交回复
热议问题