如何更改核心动画实例的帧频? [英] How to change the frame rate of a core animation instance?

查看:56
本文介绍了如何更改核心动画实例的帧频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以CABasicAnimation为例。如何降低帧率(开销)?动画运行流畅,但是我的touchesMoved方法跳过了节拍。想要降低动画帧速率,以便touchesMoved不会跳过动作。

解决方案

您对帧速率没有任何固有的控制权一旦启动CABasicAnimation。



可能最好的方法是为单个动画创建多个插值(即,如果您向下移动50 px,跨50px,则执行2 x 25px并在您的线程中进行人工睡眠。这不是一个完美的解决方案,但是可能会获得您看到的更好的结果。一般推荐。本质上是YMMV。


Take CABasicAnimation for example. How do you lower the frame rate (overhead)? Animations run smooth, but my touchesMoved method skips a beat. Want to reduce the animation frame rate so touchesMoved is not skipping movements.

解决方案

You don't have any inherent control over frame rate once you start your CABasicAnimation.

Probably the best way to achieve this would be to create multiple interpolations for a single animation (i.e. if you're moving 50 px down and 50px across, do 2 x 25px each) and induce an artificial sleep in your thread. Not a perfect solution, but will perhaps achieve slightly better results that you're seeing.

Be aware that this technique will have different framerates on different CPUs, and is therefore not generally recommended. Essentially, YMMV.

这篇关于如何更改核心动画实例的帧频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆