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 shou
Rob, you rock brother. I was looking for a way to do the same thing but vertically. After reading your answer above I had no problem adjusting it to suit my needs. For anyone that may end up here on their hunt for a vertical solution this is what I ended up with, modeled after the above:
- (IBAction)animateBackground6
{
UIImage *backgroundImage = [UIImage imageNamed:@"space.png"];
UIColor *backgroundPattern = [UIColor colorWithPatternImage:backgroundImage];
CALayer *background = [CALayer layer];
background.backgroundColor = backgroundPattern.CGColor;
background.transform = CATransform3DMakeScale(1, -1, 1);
background.anchorPoint = CGPointMake(0, 1);
CGSize viewSize = self.backgroundImageView.bounds.size;
background.frame = CGRectMake(0, 0, viewSize.width, backgroundImage.size.height + viewSize.height);
[self.backgroundImageView.layer addSublayer:background];
CGPoint startPoint = CGPointZero;
CGPoint endPoint = CGPointMake(0, -backgroundImage.size.height);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.fromValue = [NSValue valueWithCGPoint:endPoint];
animation.toValue = [NSValue valueWithCGPoint:startPoint];
animation.repeatCount = HUGE_VALF;
animation.duration = 5.0;
[background addAnimation:animation forKey:@"position"];
}