title: Animate infinite scrolling of an image in a seamless loop
body: <p>Currently I have an image of clouds of 2048x435 that scrolls across a Landscaped oriented UIImageView of 1024x435 using CABasicAnimation.  The cloud image scrolls as it should, however I am having some trouble trying to to get a duplicate clouds image to connect to the back of the the current clouds image so that there is no gap between the clouds images. I've been struggling for about a day trying to find a solution, so any help would be greatly appreciated.  My current code:</p>
  
  <p>developing on Xcode 4.2 for iOS 5 with ARC non-storyboard ipad landscaped orientation.</p>
  
  <pre><code>-(void)cloudScroll
  {
      UIImage *cloudsImage = [UIImage imageNamed:@"TitleClouds.png"];
      CALayer *cloud = [CALayer layer];
      cloud.contents = (id)cloudsImage.CGImage;
      cloud.bounds = CGRectMake(0, 0, cloudsImage.size.width, cloudsImage.size.height);
      cloud.position = CGPointMake(self.view.bounds.size.width / 2, cloudsImage.size.height / 2);
      [cloudsImageView.layer addSublayer:cloud];
  
      CGPoint startPt = CGPointMake(self.view.bounds.size.width + cloud.bounds.size.width / 2, cloud.position.y);
      CGPoint endPt = CGPointMake(cloud.bounds.size.width / -2, cloud.position.y);
      CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position"];
      anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
      anim.fromValue = [NSValue valueWithCGPoint:startPt];
      anim.toValue = [NSValue valueWithCGPoint:endPt];
      anim.repeatCount = HUGE_VALF;
      anim.duration = 60.0;
      [cloud addAnimation:anim forKey:@"position"];
  }
  
  -(void)viewDidLoad
  {
      [self cloudScroll];
      [super viewDidLoad];
  }
  </code></pre>