Chandan Shetty SP
Chandan Shetty SP

Reputation: 5117

Animating images using CAAnimation

Is it possible to implement animating sequence of images using CAAnimation? And i dont want to use UIImageView...

I need Something similar to UIImageView where we can set imageView.animationImages and calling startAnimation... but using CAAnimation

Upvotes: 2

Views: 2174

Answers (1)

Chandan Shetty SP
Chandan Shetty SP

Reputation: 5117

CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
animationSequence.calculationMode = kCAAnimationLinear;
animationSequence.autoreverses = YES;
animationSequence.duration = kDefaultAnimationDuration;
animationSequence.repeatCount = HUGE_VALF;

NSMutableArray *animationSequenceArray = [[NSMutableArray alloc] init];
for (UIImage *image in self.animationImages) 
{
    [animationSequenceArray addObject:(id)image.CGImage];
}
animationSequence.values = animationSequenceArray;
[animationSequenceArray release];
[self.layer addAnimation:animationSequence forKey:@"contents"];

Upvotes: 7

Related Questions