Toggle slow animation while debugging with iOS Device

IosXcodeIos5

Ios Problem Overview


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?

Ios Solutions


Solution 1 - Ios

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.

Solution 2 - Ios

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

Solution 3 - Ios

For Swift Apps:

Halt your code with a breakpoint and enter the following lldb command:

(lldb) p UIApplication.shared.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.

Solution 4 - Ios

Swift 5, add this line in AppDelegate or SceneDelegate class, that's depending on your base architecture :

// create and assign window object if not exist. 🤓
self.window = UIWindow(frame: UIScreen.main.bounds)

// starts slow motion 🤩
window?.layer.speed = 0.05

Solution 5 - Ios

If you want to slow down the app only in one view controller, you can configure a breakpoint to continue execution after executing the command. You set this breakpoint in viewDidAppear. Then you can set another "non-stoppable" breakpoint to reverse the speed to 1X. You set this other breakpoint in viewDidDisappear.

Very simple. Can be kept in your breakpoint list deactivated and easily reused when needed.

Solution 6 - Ios

In Objective-c works pretty good

self.window.layer.speed = .1f;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionfabregas88View Question on Stackoverflow
Solution 1 - IosTim ArnoldView Answer on Stackoverflow
Solution 2 - IosJALView Answer on Stackoverflow
Solution 3 - IosdreamlabView Answer on Stackoverflow
Solution 4 - IosasilturkView Answer on Stackoverflow
Solution 5 - IosMikaelView Answer on Stackoverflow
Solution 6 - IosMarcos DebastianiView Answer on Stackoverflow