Why ever use `keyTimes`, `timingFunctions` or `timingFunction` on CAKeyframeAnimation?

Interpolating the values with a custom function is very easy. But is it bad practice? Should I instead (or in addition) use keyTimes, timingFunctions or timingFunction to explain the animation-curve to the framework? When working with custom animation curves I really don't see why I should use those properties. I want to do this right.

This works just fine. As expected it animates the views-position with a custom cubic-ease-out animation curve:

CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position.x"];
anim.duration = 5;
NSUInteger numberOfFrames = anim.duration * 60;

NSMutableArray *values = [NSMutableArray new];

for (int i = 0; i < numberOfFrames; i++)
    CGFloat linearProgress = (double) i / (double) numberOfFrames;
    CGPoint position = view.layer.position;
    position.x = 10 + (300 * CubicEaseOut(linearProgress));
    [values addObject:[NSValue valueWithCGPoint:position]];

anim.values = values;

[view.layer addAnimation:anim forKey:@"position"];


Your method adds 300 keyframes to the animation, for Core Animation to interpolate, linearly. There are two reasons this might not be worse than using fewer keyframes with non-linear interpolation to to get the same result: (1) more data to send to CA, i.e. more data to store and read every animation frame; (2) if you ever wanted to slow down the animation so that more than 300 frames are rendered from it the linear interpolation artifacts may become visible.

If you just have one 3s animation, it's likely neither of those reasons are important, but e.g. if you had 100 10s animations all running at once you may see worse performance than if using fewer keyframes.

Need Your Help

Border color of pattern image

php image gd

I am working on image manipulation script.

The spring bean is not injected if I call a method in the post-constructed class

spring jsf-2 dependency-injection postconstruct

I am doing a spring bean injection to my jsf managed bean property for which am getting the above mentioned error. The following is the full stack trace:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.