1

ここに状況があります。

AVFoundationを使用してカメラフレームをキャプチャしています。今、私がやりたいのは、特定のフレームについて、段階的に回転する画像を表示する必要があるということです。

私がやろうとしているのは、オブジェクトの前後左右の画像で構成される4つのCALayerを取得し、CALayer時間プロパティとグループアニメーションプロパティを使用して、特定のミリ秒間隔の後にすべての画像を1つずつ表示したいということです。連続画像がアニメーションのように見えるように時間をかけます。

それについてどうやって行くのですか?ここでコーディングを手伝ってください。

4

2 に答える 2

1
-(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];

}
于 2012-06-27T05:34:49.817 に答える
1

MohitGuptaのパスティリンクに基づいて答えてください:

画像シーケンスアニメーションが必要なCALayerを設定します

CALayer *animationLayer = [CALayer layer];
[animationLayer setFrame:CGRectMake(125, 0, 240, 300)];
[self.baseLayer addSublayer:animationLayer];

シーケンスアニメーションで表示する必要のある画像の配列を定義する

NSArray *animationFrames = [NSArray arrayWithObjects:(id)[UIImageimageNamed:@"1.png"].CGImage, (id)[UIImage imageNamed:@"2.png"].CGImage, (id)[UIImage imageNamed:@"3.png"].CGImage, nil];

CAKeyframeAnimationを使用して画像の配列を順番に表示する

CAKeyframeAnimation *frameAnimation = [[CAKeyframeAnimation alloc] init];
[frameAnimation setKeyPath:@"contents"];
frameAnimation.calculationMode = kCAAnimationDiscrete; //mode of transformation of images
[animationLayer setContents:[animationFrames lastObject]]; //set the array objects as encounterd
frameAnimation.autoreverses = NO; //If set Yes, transition would be in fade in fade out manner
frameAnimation.duration = ((float)[animationFrames count])/4.5; //set image duration , it can be predefined float value
frameAnimation.repeatCount = HUGE_VAL; //this is for inifinite, can be set to any integer value as well
[frameAnimation setValues:animationFrames];
[frameAnimation setRemovedOnCompletion:YES];
[frameAnimation setDelegate:self];
[animationLayer addAnimation:frameAnimation forKey:@"contents"]; //add animation to your CALayer
[frameAnimation release];

お役に立てれば

于 2012-06-27T06:29:15.190 に答える