What is the default animation easing function in i

2019-04-01 03:50发布

问题:

In iOS animations is the default easing function (UIViewAnimationOptionCurveEaseInOut) a quadratic or a cubic? Or what else?

回答1:

It's a cubic bézier curve. The precise control points aren't documented, so they could change between releases, but you can get them via CAMediaTimingFunction:

CAMediaTimingFunction *func = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
for (int i = 0; i < 4; i++) {
    float *values = malloc(sizeof(float) * 2);
    [func getControlPointAtIndex:i values:values];
    NSLog(@"Control point %i: (%f, %f)", i+1, values[0], values[1]);
    free(values);
}

The values I get with this are (0.0, 0.0), (0.42, 0.0), (0.58, 1.0), (1.0, 1.0), which corresponds roughly to this curve:



标签: ios animation