0

スプラッシュ スクリーン用に複数の画像をアニメーション化しようとしています。スプラッシュ スクリーンとして 3 つの画像を表示しています。

スプラッシュ画面を変更しながら画像をフェードアウトさせたい。NSTimmerソリューションを試しましたが、3番目の画像とメイン画面を直接表示しますこのソリューションを試した後よりも、2番目と3番目の画像が2回ずつ表示されます。どんな助けでも大歓迎です

編集済み/-ニッキは私にいくつかの解決策を提案しますが、2番目の画像ビューを非表示にした場所はどこですか? これが私のコードです

backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
backgroundImageView.image=[UIImage imageNamed:@"SPLASHSCREEN-2.png"];
backgroundImageView2 = [[UIImageView alloc] initWithFrame:self.view.bounds];
backgroundImageView2.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
backgroundImageView2.image=[UIImage imageNamed:@"SPLASHSCREEN-3.png"];
[self.view addSubview:backgroundImageView];
[self.view addSubview:backgroundImageView2];
[backgroundImageView2 setHidden:YES];
[self performSelector:@selector(performTransition) withObject:nil afterDelay:1.0];

-(void)performTransition
   {
CATransition *animation3 = [CATransition animation];
[animation3 setDuration:3.0f];
[animation3 setType:kCATransitionReveal];
[animation3 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[backgroundImageView layer] addAnimation:animation3 forKey:@"SwitchToView"];
[backgroundImageView setHidden:YES];
[backgroundImageView2 setHidden:NO];//No animation happen while changing the image view
}
4

1 に答える 1

1

最初に表示する 2 つを作成し、ImageView最初は非表示に設定できます。アニメーション化するコードを書くだけです:

-(void)performTransition
{  
  CATransition *animation3 =  [CATransition animation];
  [animation3  setDuration:3.0f];
  [animation3  setType:kCATransitionReveal];
  [animation3  setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
  [[backgroundImageView2  layer] addAnimation:animation3 forKey:@"SwitchToView"];
  [backgroundImageView  setHidden:YES];
  [backgroundImageView2  setHidden:NO];//No animation happen while changing the image view
} 

そして、ImageView が再表示中にアニメーション化されるように設定します。の値を変更することで、アニメーションの種類を変更できます[animation3 setType:kCATransitionReveal];。インポートすることを忘れないでください:#import<QuartzCore/QuartzCore.h>

アニメーションで前ImageViewを非表示にし、アニメーションで次ImageViewを表示するには、関数内にコードを記述し、使用してその関数を呼び出し、performSelector必要な時間間隔を追加できます。

于 2013-03-08T14:24:55.653 に答える