views:

71

answers:

2

Hello! Is it possible to use Core Animation to change something else than properties of CALayers? I’d like to use a simple property animation with easing to change a value on my model class. Something like this:

CABasicAnimation* anim = [CABasicAnimation animation];
anim.keyPath = @"someProperty";
anim.fromValue = [NSNumber numberWithFloat: 0.0];
anim.toValue = [NSNumber numberWithFloat: 1.5];
anim.duration = 1.0;
anim.timingFunction = [CAMediaTimingFunction 
    functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

And then call something like [anim update] until the animation finishes.

+1  A: 

The layer classes (CALayer and it's subclasses) are the foundation of Core Animation. These classes provide content for display. So, no you can't use Core Animation without somehow using CALayers.

I would suggest reading through Apple's description of Core Animation. From what you are describing, you would like to use the Core Animation class CABasicAnimation to inform your model class what a certain value should be over the course of an animation's duration. Core Animation's classes are not designed to be used that way, or used with anything else besides the Core Animation framework.

What you are really looking for is a class/library that can provide you with timed interpolations between values, from a purely mathematical perspective, rather than animation. Perhaps there is some open source code out there that can do that for you.

CJ
+1  A: 

One can use the CABasicAnimation which operates on a CALayer, without using the CALayer itself; but to query its -(id)presentationModel. One can even add their own keys to CALayer with which to animate in this way

humasect