How to change the frame rate of a core animation i

2019-05-23 12:49发布

问题:

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.

回答1:

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.