我正在使用以下代码
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 175, 175)];
// load all the frames of our animation
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"a1.png"],
[UIImage imageNamed:@"a2.png"],
[UIImage imageNamed:@"a3.png"],
[UIImage imageNamed:@"a4.png"],
[UIImage imageNamed:@"a5.png"],
[UIImage imageNamed:@"a6.png"],
[UIImage imageNamed:@"a7.png"],
[UIImage imageNamed:@"a8.png"],
[UIImage imageNamed:@"a9.png"],
[UIImage imageNamed:@"a10.png"],
nil];
// all frames will execute in 1.75 seconds
campFireView.animationDuration = 0.75;
// repeat the annimation forever
campFireView.animationRepeatCount = 0;
// start animating
[campFireView startAnimating];
// add the animation view to the main window
[self.view addSubview:campFireView]; // [campFireView release];
这适用于a1到a10, 我怎样才能继续按相反的顺序移动,那么它应该将a1设置为a10到a1连续动画吗?
答案 0 :(得分:1)
campFireView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"a1.png"],
[UIImage imageNamed:@"a2.png"],
[UIImage imageNamed:@"a3.png"],
[UIImage imageNamed:@"a4.png"],
[UIImage imageNamed:@"a5.png"],
[UIImage imageNamed:@"a6.png"],
[UIImage imageNamed:@"a7.png"],
[UIImage imageNamed:@"a8.png"],
[UIImage imageNamed:@"a9.png"],
[UIImage imageNamed:@"a10.png"],
[UIImage imageNamed:@"a9.png"],
[UIImage imageNamed:@"a8.png"],
[UIImage imageNamed:@"a7.png"],
[UIImage imageNamed:@"a6.png"],
[UIImage imageNamed:@"a5.png"],
[UIImage imageNamed:@"a4.png"],
[UIImage imageNamed:@"a3.png"],
[UIImage imageNamed:@"a2.png"],
[UIImage imageNamed:@"a1.png"],
nil];