Toggle Slow Animations

iOS Simulator has a feature that slows animations, you can toggle it either by pressing ⌘T or choosing Debug > Toggle Slow Animations in Frontmost App. It’s very useful, but what if we want to do the same on device? It’s easy, fast and simple.

CALayer has a property called speed, which is a time multiplier. This means that if we have an animation with a duration of 1 second, and set the layer’s speed to 2, it’ll take just 0.5 seconds to finish. The best thing about it is that it’s related to the parent layer. So when we change the speed of a particular CALayer, every child layer will be affected. So, if we change UIWindow layer speed, every CALayer in our application will perform animations with that custom speed value. That leaves us with this two extensions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extension UIWindow {

    var slowAnimationsEnabled: Bool {
get {
return layer.speed != 1
}
set {
layer.speed = newValue ? 0.2 : 1
}
}
} extension UIApplication { func setSlowAnimationsEnabled(enabled: Bool) {
windows.map({ window in (window as? UIWindow)?.slowAnimationsEnabled = enabled })
}
}

And you can call it in both ways:

1
2
UIApplication.sharedApplication().keyWindow?.slowAnimationsEnabled = true
UIApplication.sharedApplication().setSlowAnimationsEnabled(true)

You can go further and expose this to your testers, through iOS Settings Bundle or a fancy shake gesture. Pretty handy!

Toggle Slow Animations的更多相关文章

  1. iOS.Animations.by.Tutorials.v2.0汉化(四)

    第三章 转换 在前面的两章,你学习了如何创建基于视图位置和透明度alpha的动画属性的动画.但是,如果您希望在视图上添加动画或删除动画,您将如何处理呢? 您可以使用前几章的方法来设置进出界面的动画效果 ...

  2. iOS-调试技巧

    目录 前言逼优鸡知己知彼 百战不殆抽刀断Bug 普通操作 全局断点(Global BreakPoint) 条件断点(Condational Breakpoints)打印的艺术 NSLog 开启僵尸对象 ...

  3. iOS各种调试技巧豪华套餐

    转载自http://www.cnblogs.com/daiweilai/p/4421340.html 目录 前言 逼优鸡 知己知彼 百战不殆 抽刀断Bug 普通操作 全局断点(Global Break ...

  4. xcode的调试技巧

    转自:http://www.cnblogs.com/daiweilai/p/4421340.html#biyouji 目录 前言逼优鸡知己知彼 百战不殆抽刀断Bug 普通操作 全局断点(Global ...

  5. [翻译] POP Facebook的动画开源库

    Pop is an extensible animation engine for iOS and OS X. In addition to basic static animations, it s ...

  6. iOS调试程序的方法

    IOS各种调试技巧豪华套餐 普通操作 如图3 基本的断点操作如下 图4 点击那个黑列列就创建了一个断点,再次点击就临时取消这个断点(但是不删除),长按那个断点拖出去就删除了(mac os的系统工程师就 ...

  7. 使用Xcode进行调试

    目录 知己知彼 百战不殆抽刀断Bug 普通操作 全局断点(Global BreakPoint) 条件断点(Condational Breakpoints)打印的艺术 NSLog 开启僵尸对象(Enab ...

  8. iOS_高效开发之道

    iOS_高效开发之道 话不多说, 总结一下个人感觉有利于提高iOS开发效率的几个小技巧. 本文将从下面几方面介绍: Xcode经常使用快捷键 Xcode调试技巧 Objc经常使用代码片段 Xcode插 ...

  9. iOS 开发常用的调试工具

    前言 最近博主临近毕业季,为了完美的写一篇毕业论文,真是:“锄禾日当午,汗滴禾下土”<—— 这句诗跟毕业我写毕业论文没任何一毛钱关系,我就是突然想吟湿了.不过博主作为网络工程专业的好青年,曾经的 ...

随机推荐

  1. 3.4 自动测试初步《精通ASP.NET MVC 5》

    概述 ASP.NET MVC 框架已被设计成易于建立自动测试,并易于采用诸如测试驱动开发(TDD)等的开发方法学.ASP.NET MVC 为自动化测试提供了一个理想平台. 从广义上讲,当今的 Web ...

  2. AIX详细查看用户/进程使用内存

    本文来自:https://blog.csdn.net/mydriverc2/article/details/41956063 问题描述:通过topas发现%comp内存已使用98% 问题分析: 1,从 ...

  3. Scratch安装使用教程

    一.说明 一直听说scratch是一款麻省理工所开发的很好的少儿编程学习工具,一直不是很清楚所谓少儿编程是长什么样所以探究了一下. 二.安装 scratch当前到了3.0版本,3.0版本默认直接是we ...

  4. 运用python绘制小猪佩奇

    用python绘制小猪佩奇 1.打开idle 2.点击File-New Files 3.输入以下代码 1. from turtle import * 2. 3. def nose(x,y):#鼻子 4 ...

  5. vue2.0项目 calendar.js(日历组件封装)

    最近一直闲来无事,便寻思着做一下自己的个人项目,也想说能使用现在比较流行的一些mvvm框架来做,于是就选用了这样的一个技术栈vue2.0+vue-router+vuex+webpack来做,做得也是多 ...

  6. 转载:Shell 脚本加密 - 略有修改

    shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件. shc 安装 yum -y install shc 如果yum不能安装,请移步官方下载rpm包 http ...

  7. ThinkPHP5.0 开发手册

    ThinkPHP5.0开发手册地址 https://www.kancloud.cn/manual/thinkphp5/118003 此博文仅仅作为个人笔记存储,没有广告,宣传的意图

  8. 装B命令行,常用Windows命令

    winver检查Windows版本 dxdiag检查DirectX信息 gpedit.msc 组策略   regedit.exe 注册表 Msconfig.exe 系统配置实用程序  lusrmgr. ...

  9. result type

    <result-types> <result-type name="chain" class="com.opensymphony.xwork2.Acti ...

  10. 洛谷P1993 小K的农场

    思路是差分约束+dfs版SPFA. 首先来思考差分约束的过程,将题目给出的式子进行转化: 农场a比农场b至少多种植了c个单位的作物, SPFA我们考虑跑最短路,那么要让SPFA中满足的式子就是if(d ...