我这里有个情况。
我正在使用AVFoundation捕获相机框架。
现在我要做的是对于某些帧,我需要显示一张逐步旋转的图片。
我想做的是,我要拍摄4个CALayers,其中包括一个对象的前后左右图像,并使用CALayer time属性和group animation属性,我想每隔一定的毫秒间隔显示所有图像时间,以便连续图像看起来像是动画。
怎么做呢?请帮助我进行一些编码。
最佳答案
-(void)startMainAnimation
{
//Animationframes is array of images that should be CGImage Type not UIImage..
//animation Layer that is added above view……
CAKeyframeAnimation *frameAnimation = [[CAKeyframeAnimation alloc] init];
[frameAnimation setKeyPath:@"contents"];
frameAnimation.calculationMode = kCAAnimationDiscrete;
[animationLayer setContents:[animationFrames lastObject]];
frameAnimation.autoreverses = NO;
frameAnimation.duration = ((float)[animationFrames count])/4.5;;
frameAnimation.repeatCount = 1;
[frameAnimation setValues:animationFrames];
[frameAnimation setRemovedOnCompletion:YES];
[frameAnimation setDelegate:self];
[animationLayer addAnimation:frameAnimation forKey:@"contents"];
[frameAnimation release];
}