我被困在动画 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"];
}