使用CAAnimation动画图片 [英] Animating images using CAAnimation

查看:216
本文介绍了使用CAAnimation动画图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能实现动画使用CAAnimation图像序列?我不想使用的UIImageView ...

我需要类似的UIImageView的东西在这里我们可以设置imageView.animationImages并呼吁startAnimation ......但使用CAAnimation


解决方案

  CAKeyframeAnimation * animationSequence = [CAKeyframeAnimation animationWithKeyPath:@内容];
animationSequence.calculationMode = kCAAnimationLinear;
animationSequence.autoreverses = YES;
animationSequence.duration = kDefaultAnimationDuration;
animationSequence.repeatCount = HUGE_VALF;NSMutableArray里* animationSequenceArray = [[NSMutableArray里的alloc]初始化];
对于(*的UIImage在self.animationImages图片)
{
    [animationSequenceArray ADDOBJECT:(ID)image.CGImage]
}
animationSequence.values​​ = animationSequenceArray;
[animationSequenceArray发布]
[self.layer addAnimation:animationSequence forKey:@内容];

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

解决方案

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"];

这篇关于使用CAAnimation动画图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆