Toggle slow animation while debugging with iOS Device
I'm using xCode 4.3.1 and I need to use the option that the iOS Simulator has => Debug -> Toggle Slow Animation but while debugging with the iOS Device.
Is it possible?
It's not possible in exactly the same way as with the Simulator, but there is a good way to accomplish the same effect using lldb.
Use the debugger to pause code execution, and then enter the command:
p [(CALayer *)[[[[UIApplication sharedApplication] windows] objectAtIndex:0] layer] setSpeed:.1f]
into the debugger.
Thanks to this link for the solution.
In Swift 3:
UIApplication.shared.windows.first?.layer.speed = 0.1
Or, if you're anywhere in your AppDelegate and you only use one window, you can do this:
window?.layer.speed = 0.1
For Swift Apps:
Halt your code with a breakpoint and enter the following lldb command:
(lldb)
p UIApplication.sharedApplication().windows.first?.layer.speed = 0.1
Alternatively you can obviously also change the speed somewhere in you code. For example with an #if
preprocessor macro at application launch
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
...
#if DEBUG
application.windows.first?.layer.speed = 0.1
#endif
Don't forget to set the DEBUG
symbol in the "Swift Compiler - Custom Flags" section, "Other Swift Flags" line. You add the DEBUG
symbol with a -DDEBUG
entry.