0
[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.

AndyW
  • 985
  • 3
  • 10
  • 21
  • 1
    What do you mean "the frame rate of animateWithDuration" ? – Guillaume Algis Apr 23 '14 at 20:25
  • possible duplicate of [UIView animateWithDuration: duration: animations: completion: seems to have a default transition?](http://stackoverflow.com/questions/10794763/uiview-animatewithduration-duration-animations-completion-seems-to-have-a-de) – Guillaume Algis Apr 23 '14 at 20:26
  • Not a duplicate of the above. I want to copy the effect of the UIViewAnimationOptionCurveEaseInOut option, using my own custom made algorithm for animating views. The algorithm I've written draws the UIView at interval positions X times a second. The animateWithDuration method will work in the same way - I want to know the value for X in the animateWithDuration method. – AndyW Apr 23 '14 at 20:45
  • "The algorithm I've written draws the UIView at interval positions X times a second." Why would you rather do that? What is it that you can't do with UIView animations or Core Animation? Building your own system is very seldom the right solution. – David Rönnqvist Apr 23 '14 at 20:58
  • In short I have a custom framework that I'm already using in my apps to place controls etc. I also have an (almost) identical framework in java, which allows the android version to look the same easily. I've been having a lot of trouble getting animateWithDuration to behave exactly how I want it to. With the animation code I've written I can know the android/iOS versions are doing the same thing. – AndyW Apr 24 '14 at 20:19

1 Answers1

1

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.

Sulthan
  • 128,090
  • 22
  • 218
  • 270