Animating "contents" property of CALayer via the delegate
Animating "contents" property of CALayer via the delegate
- Subject: Animating "contents" property of CALayer via the delegate
- From: Oleg Krupnov <email@hidden>
- Date: Mon, 28 Sep 2009 14:16:36 +0300
I'd like to use Core Animation to create an arbitrary animation, that
is, I have a number of custom-drawn frames that I want to render in a
sequence, with a good frame rate, using the Core Animation timing
engine. How do I do this?
I am looking on CAKeyframeAnimation, which could do the job using the
code like this:
CAKeyframeAnimation *anim;
NSMutableArray *images;
CGImageRef im;
int i;
images = [NSMutableArray array];
for (i = 0; i < N; i++) {
im = create_image (i);
[images addObject:(id)im];
CGImageRelease (im);
}
anim = [CAKeyframeAnimation animation];
[anim setKeyPath:@"contents"];
[anim setValues:images];
[anim setCalculationMode:@"discrete"];
[anim setRepeatCount:HUGE_VAL];
[anim setDuration:1.0];
[layer addAnimation:anim];
However, I don't like to create all keyframe images at once, but
instead draw them in process of animation, when the particular frame
becomes the current frame, via the -[CALayer drawLayer:inContext:]
delegate method. How do I do this? The delegate method seems to get
called only once. Thanks!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden