Last active
September 17, 2021 16:23
-
-
Save fruitcoder/94bf787671e805675e1f7bb6770d389d to your computer and use it in GitHub Desktop.
Returns the simulator drag coefficient when Slow Animations are enabled, otherwise (and non simulator builds) 1.0
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
import UIKit | |
#if targetEnvironment(simulator) | |
@_silgen_name("UIAnimationDragCoefficient") func UIAnimationDragCoefficient() -> Float | |
func simulatorDragCoefficient() -> CFTimeInterval { | |
let drag = UIAnimationDragCoefficient() | |
if drag > 1 { | |
return CFTimeInterval(drag) | |
} | |
return 1 | |
} | |
#else | |
func simulatorDragCoefficient() -> CFTimeInterval { 1 } | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disclaimer: This works by pure accident, it can break any time. Do not use
_silgen_name
in production! https://twitter.com/harlanhaskins/status/1331637798311366657?s=21