Created
November 1, 2016 14:54
-
-
Save owenzhao/9a5247709072376f68cf67af9e013d2d to your computer and use it in GitHub Desktop.
stop main runloop to change the running order of progress indicator
This file contains 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
func userDefaultsDidChange() { | |
guard let controller = tableViewController else { return } | |
let progressIndicator = { () -> NSProgressIndicator in | |
let frame = view.frame | |
let x = (frame.width - 50) / 2 | |
let y = (frame.height - 50) / 2 | |
let piFrame = NSMakeRect(x, y, 50, 50) | |
let pi = NSProgressIndicator(frame: piFrame) | |
pi.style = .spinningStyle | |
return pi | |
}() | |
view.addSubview(progressIndicator) | |
progressIndicator.startAnimation(self) | |
RunLoop.main.run(until: Date(timeIntervalSinceNow: 0.001)) | |
controller.run() | |
progressIndicator.stopAnimation(self) | |
progressIndicator.removeFromSuperview() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment