Reputation: 163
How can I create a continuous animation with an image in iOS? i want to create a looping action where an imageView of mine stays within the screen boundaries but the x axis constantly forward so it would basically generate a animation effect.. so i have to use only one image. any help would be greatly appreciated!! ideas?
my image is a large one in 800*12 pixels .
Upvotes: 2
Views: 1486
Reputation: 8785
You can use the animationImages
property of UIImageView to animate the frames of your animation:
UIImageView *view = // etc.
UIImage *frame1 = [UIImage imageNamed:@"1.png"];
UIImage *frame2 = [UIImage imageNamed:@"2.png"];
// etc.
view.animationImages = [NSArray arrayWithObjects:frame1, frame2, ..., nil];
view.animationDuration = 1.0;
view.animationRepeatCount = 0;
[view startAnimating];
Upvotes: 5