我卡上的动画2幅图像能够在iPhone上查看水平滚动无限。 背景不能有任何空隙。 如果这可以只用1图像来完成,这将是伟大的,但我似乎无法得到它。 这里是我到目前为止的代码:
-(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"];
}