Created
May 27, 2018 18:19
-
-
Save bob910078/7633f2bc71c0578d360a8eeec4a6409c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 延遲指定時間 (可搭配 activity indicator 使用) | |
func delay(_ seconds: Double, completion: @escaping ()->()) { | |
let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC) | |
DispatchQueue.main.asyncAfter(deadline: dispatchTime) { | |
completion() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment