1.定時器:NSTimer類的函數,scheduledTimerWithTimeInterval()swift
根據字面意思:用時間間隔設置定時器。函數
例子(結合progressView製做加載動畫):動畫
另外,該函數(schedulerTimerwithTimeInterval)是會返回改定時器的對象的,因此回調函數的參數列表應該傳入一個NSTimer對象如上。code
2. 指定回調函數的格式:對象
#selector(當前類名.回調函數名 或 self.回調函數名),不管是否有返回值給回調函數也是這種格式。如:回調函數
func progressAction(sender: NSTimer) { //回調函數內容 //使定時器失效的方法: sender.invalidate() }