我已经在 UIImageView 中加载了一组图像。如何使用 CoreAnimation 为 UIImageView 中的图像设置动画?请给我建议
问问题
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 回答