IPhone CALayer Array Content Values

The way to load an image onto a layer is simple:

CALayer *layer = [[CALayer alloc]init];

layer.contents = (id) [UIImage imageNamed:@"image.png"].CGImage;

then you add a layer as a sublevel to a kind of something like:

suppose you are in the view

[self.layer addSublayer:layer];

Now I want to load an array of images as an animation, so that in the end I get an animation of the images.

so before doing the animation, I tested the following:

[values insertObject:(id)[UIImage imageNamed:path].CGImage atIndex:i];

of course, there is a loop that starts, which introduces each image to the right index ... and then I get an array CGImage.. for animation.

I printed this array and saw this:

CGImage 0x17d900

CGImage 0x17f4e0

So, there are values ​​.. and I get no errors .. but I do not see the images ...

Let me know if you have an idea ....

+5
1

, :

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
animation.calculationMode = kCAAnimationDiscrete;
animation.duration = 1.0;
animation.values = values; // NSArray of CGImageRefs
[layer addAnimation: animation forKey: @"contents"];

iPhone/iPod, . , (IIRC, CABackingStore). , CALayer , drawInContext: , , , display . , - : layer1.contents = layer2.contents.

, .

+5

All Articles