UIImageViewにロードされた画像のセットを設定しました。CoreAnimationを使用してUIImageViewで画像をアニメーション化するにはどうすればよいですか?Plzは私に提案をします
2253 次
2 に答える
3
タイマーの残りの秒に応じてアニメーションで画像をアラームするタイマーを設定すると、残りの時間で画像をアニメーション化するための非常に優れたコードです。花を作るために画像を使用しました
{
//-----------------画像アニメーション-------------------//
-(void)imageAnimationMethod
{
imageAnimation=[[UIImageView alloc]initWithFrame:CGRectMake(20, 150, 135, 135)];
[ self.view addSubview:imageAnimation];
imageAnimation.animationImages=[NSArray arrayWithObjects:
[UIImage imageNamed:@"101.png"],
[UIImage imageNamed:@"102.png"],
[UIImage imageNamed:@"103.png"],
[UIImage imageNamed:@"104.png"],
[UIImage imageNamed:@"105.png"],
[UIImage imageNamed:@"106.png"],
[UIImage imageNamed:@"107.png"],
[UIImage imageNamed:@"108.png"],
[UIImage imageNamed:@"109.png"],
[UIImage imageNamed:@"110.png"],
[UIImage imageNamed:@"111.png"],
[UIImage imageNamed:@"112.png"],
[UIImage imageNamed:@"113.png"],
[UIImage imageNamed:@"114.png"],
[UIImage imageNamed:@"115.png"],
[UIImage imageNamed:@"116.png"],
nil];
//-----remaining はタイマーの残り秒です---------//
int i=remaining*16/16;
imageAnimation.animationDuration=i;
imageAnimation.animationRepeatCount=0;
}
}
于 2012-08-24T06:34:45.980 に答える
2
imageView で一連の画像をアニメーション化するだけの場合は、以下のコードが役立ちます
UIImageView* animatedImageView = [[UIImageView alloc]init];
animatedImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"1.gif"],
[UIImage imageNamed:@"2.gif"],
[UIImage imageNamed:@"3.gif"],
[UIImage imageNamed:@"4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];
于 2012-04-18T06:27:15.173 に答える