Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if slow animations is on / off in iOS Simulator in code

I want to programatically detect if slow animations is on or off in simulator.

Something like this would be handy.

IPHONE_SIMULATOR_SLOW_ANIMATIONS_ENABLED()

This is for development purposes only.

like image 839
hfossli Avatar asked Nov 07 '12 17:11

hfossli


1 Answers

How to do this in Swift 3.0:

@_silgen_name("UIAnimationDragCoefficient") func UIAnimationDragCoefficient() -> Float

func slowAnimationsEnabled() -> Bool {
    return UIAnimationDragCoefficient() != 1.0
}

Note that unfortunately you can't use TARGET_IPHONE_SIMULATOR at compile time in Swift, and you should not include this in your App Store submissions as you may be rejected for using private APIs.

like image 59
stu Avatar answered Sep 30 '22 16:09

stu