Question

[UIView animateWithDuration: animations:^{}]

I'm replacing the use of the above with my own custom animation method. However, I quite like the standard effect this has.

So my question is what is the frame rate of animateWithDuration?

And what is the function for animateWithDuration? I don't need to know an algorithm for how to implement it or anything, just the mathematical equation for the speed/acceleration.

Was it helpful?

Solution

The "speed" function is easy to inspect. CocoaTouch animations are implemented using Core Animation and the "speed" is implemented using a CAMediaTimingFunction:

CAMediaTimingFunction *function = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];

Then you call getControlPointAtIndex:values: to get the control points of the timing function curve (cubic Bezier).

Of course, frame rate depends on device display, GPU (+ other HW components) and current load. Of course, you shouldn't care about frame rate at all. Work only with time from the start of the animation.

However, replacing the default animations with your own implementation is almost always a mistake. The animations are very easy to use and you can't really beat their performance. If you need more complicated animations, going for lower level Core Animation is possible. Replacing animations from scratch is ... a very bad idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top