`contentOffset` animation performance: `CABasicAnimation` vs UIView Animation Blocks vs `Timer` with manual set

16 views Asked by At

I want to constantly, infinitely animate UIScrollView's contentOffset.

I have 4 options:

  • set off a Timer 60 times per second and manually set contentOffset without explicit animation
  • create a single CABasicAnimation
  • animate using a single call to UIView.animate
  • use UIViewPropertyAnimator

Question: are there any favorites in terms of minimizing CPU strain?

My assumption is that basically 95% of resource will be used on re-rendering. All of these methods will involve setting contentOffset and rerendering the scene. The only difference will really be the trigger. In one case, it will be a literal Timer, while in the others it will be CADisplayLink.

I am right in assuming that it will barely make any difference? Is Timer approach somehow radically worse than proper animations?

0

There are 0 answers