Reputation: 3617
I have a simple image which I want to animate in up and down...How do I achieve it in iPhone app?
Please help
Thanks
Upvotes: 0
Views: 739
Reputation: 50697
You can use an array of images and animate them in 1 UIImage:
@interface UIImage (WrightsCS)
+(UIImage *)animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration;
@end
if ( SYSTEM_VERSION_GREATER_THAN(@"5.0") )
{
NSArray *animationFrames = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image_0.png"],
[UIImage imageNamed:@"image_1.png"],
[UIImage imageNamed:@"image_3.png"],
[UIImage imageNamed:@"image_4.png"], nil];
UIImage * animatedImage = [UIImage animatedImageWithImages:animationFrames duration:2.0f];
}
Upvotes: 2
Reputation: 150565
Have you looked at any of the Core Animation documents?
What I would do is to create a CALayer, add the image to its contents. position it just outside the view. add it as a sublayer to the the UIView's layer and then set the position of this layer to be where you want it to animate to.
That should give you enough of a hint to get started. When you get the hang of that you can look at doing more complicated animations.
Upvotes: 0