无尽的重复滚动/animation背景在iOS?

我卡在animation2水平无限滚动的iPhone视图的图像。 背景不能有任何的差距。 如果这可以完成只有一个图像,这将是伟大的,但我似乎无法得到它。 这是我迄今为止的代码:

-(void)moveImages { CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; theAnimation.duration=10; theAnimation.repeatCount=100; theAnimation.autoreverses=NO; theAnimation.fromValue=[NSNumber numberWithFloat:320]; theAnimation.toValue=[NSNumber numberWithFloat:-320]; [theImage.layer addAnimation:theAnimation forKey:@"animateLayer"]; CABasicAnimation *theAnimation2; theAnimation2=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; theAnimation2.duration=10; theAnimation2.repeatCount=100; theAnimation2.autoreverses=NO; theAnimation2.fromValue=[NSNumber numberWithFloat:640]; theAnimation2.toValue=[NSNumber numberWithFloat:-640]; [theImage2.layer addAnimation:theAnimation2 forKey:@"animateLayer2"]; } 

那么,在代码中,你可以创build一个新的图像,这是这两个组合。 这幅合成图像的宽度为960像素,并将第一个图像复制到最右边和最左边的位置。 中间位置是第二个图像。

你开始图像左移640像素,所以你只能看到第一个图像。 然后你animation640像素。 当您重新开始animation时,图像始终左移640像素。

这样你有一个animation。