Guglie
Guglie

Reputation: 2441

What is the default animation easing function in iOS?

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

Upvotes: 6

Views: 5591

Answers (1)

omz
omz

Reputation: 53551

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:

Curve

Upvotes: 15

Related Questions