Skip to content

Instantly share code, notes, and snippets.

@KyLeggiero
Created May 7, 2019 18:22
Show Gist options
  • Save KyLeggiero/63f84d5f7fd8c9b3c9501d1b68110983 to your computer and use it in GitHub Desktop.
Save KyLeggiero/63f84d5f7fd8c9b3c9501d1b68110983 to your computer and use it in GitHub Desktop.
NSAnimationContext.runAnimationGroup in OS X 10.11 and older
// By Ben Leggiero on 2019-05-07
// License is BH-1-PS: https://github.com/BlueHuskyStudios/Licenses/blob/master/Licenses/BH-1-PS.txt
import AppKit
public extension NSAnimationContext {
/// Allows those who must support old versions of macOS / OS X to use the better, modern block syntax
public static func __shim__runAnimationGroup(_ changes: (NSAnimationContext) -> Void,
completionHandler: (() -> Void)? = nil) {
if #available(macOS 10.12, *) {
return runAnimationGroup(changes, completionHandler)
}
else {
beginGrouping()
current.completionHandler = completionHandler
changes(current)
endGrouping()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment