Mimic Apple UIViewAnimationOptionCurveEaseInOut math equation?

I want to create an animation that will look just like Apple CurveEaseInOut, so that my application looks consistent. The problem is that this animation cannot use the UIView animation method. I have to manually manipulate the position in each frame. For example, I get the time T, and I need to deduce the center of C for the point at that time. Instead of using a linear dependency (like C = T), I want it to lighten and disappear like Apple does.

What curve equation does Apple use for this animation option?

I assume the curve looks something like this: (which was taken from this question )

enter image description here

If so, it seems like I should just fine-tune the Cubic Hermite spline with the correct constants and get the same result. The question is, which constants does Apple use?

+4
source share
2 answers

As carboxylic acid (H2CO3) pointed out, the question is which control points Apple uses.

Assuming this is the same as the default sync feature in Core Animation, you can get breakpoints from the documentation:

kCAMediaTimingFunctionDefault Defines the default synchronization function for most animations. It approximates the Bezier synchronization function using the control points [(0,0,0,0,0), (0,25,0,1), (0,25,0,1), (1,0,1,0)] . Using this constant, you guarantee that your animations will use the current time by default.


edit

Since you mentioned custom animation, I highly recommend you watch the presentation of the properties of the custom animation layer of Rob Napier . You benefit from Core Animation while still making your own animations. (Watch the entire presentation. This helps to understand most of the main animation)

+3
source

Simon Whitaker has an online javascript configurator for CAMediaTimingFunction .

His code resets these breakpoints:

 linear (0.00, 0.00), (0.00, 0.00), (1.00, 1.00), (1.00, 1.00) easeIn (0.00, 0.00), (0.42, 0.00), (1.00, 1.00), (1.00, 1.00) easeOut (0.00, 0.00), (0.00, 0.00), (0.58, 1.00), (1.00, 1.00) easeInEaseOut (0.00, 0.00), (0.42, 0.00), (0.58, 1.00), (1.00, 1.00) default (0.00, 0.00), (0.25, 0.10), (0.25, 1.00), (1.00, 1.00) 
+1
source

Source: https://habr.com/ru/post/1478911/


All Articles