连续60秒连续显示多个CALayer? [英] Displaying Multiple CALayers one after another continuously for 60 seconds?
问题描述
我在这里遇到了一个情况。
I have a situation over here.
我正在使用AVFoundation捕获摄像机帧。
现在我要做的是对于某些帧,我需要显示一张逐步旋转的图片。
I am using AVFoundation to capture the camera frame. Now what i want to do is that for certain frames, i need to display a picture which revolves in a step by step fashion.
我正在尝试要做的是,我要拍摄4个CALayers,包括一个对象的前后左右图像,并使用CALayer time属性和group animation属性,我想在一定的毫秒间隔后逐个显示所有图像,以便连续图像似乎就像是动画。
What I am trying to do is that I am taking 4 CALayers comprising of front back left and right images of an object and using CALayer time property and group animation property, i want to display all the images one by one after certain milli seconds interval of time so that the continuous images seems to be like an 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];
}
这篇关于连续60秒连续显示多个CALayer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!