iphony
iphony

Reputation: 536

iphone sdk: How to animate set of images in UIImageView using CoreAnimation?

I've set of images loaded in UIImageView. How to animate the images in UIImageView using CoreAnimation? Plz give me suggesstions

Upvotes: 0

Views: 2258

Answers (2)

Jaspreet Singh
Jaspreet Singh

Reputation: 1180

it is very nice code for animating images with remaining time if you set the timer for alarm the images in animating according to the remaining sec of the timer i have used the images for make the flower

{

//-----------------image Animation-------------------//

-(void)imageAnimationMethod

   {

 imageAnimation=[[UIImageView alloc]initWithFrame:CGRectMake(20, 150, 135, 135)];


  [ self.view addSubview:imageAnimation];

 imageAnimation.animationImages=[NSArray arrayWithObjects:
                                [UIImage imageNamed:@"101.png"],
                                [UIImage imageNamed:@"102.png"],
                                [UIImage imageNamed:@"103.png"],
                                [UIImage imageNamed:@"104.png"],
                                [UIImage imageNamed:@"105.png"],
                                [UIImage imageNamed:@"106.png"],
                                [UIImage imageNamed:@"107.png"],
                                [UIImage imageNamed:@"108.png"],
                                [UIImage imageNamed:@"109.png"],
                                [UIImage imageNamed:@"110.png"],
                                [UIImage imageNamed:@"111.png"],
                                [UIImage imageNamed:@"112.png"],
                                [UIImage imageNamed:@"113.png"],
                                [UIImage imageNamed:@"114.png"],
                                [UIImage imageNamed:@"115.png"],
                                [UIImage imageNamed:@"116.png"],

                             nil];

//-----remaining is the second remaining of the timer---------//

  int i=remaining*16/16;


  imageAnimation.animationDuration=i;

  imageAnimation.animationRepeatCount=0;



 }
 }

Upvotes: 3

sElanthiraiyan
sElanthiraiyan

Reputation: 6268

If you want to just animate set of images in an imageView, the below code will help

UIImageView* animatedImageView = [[UIImageView alloc]init];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                                     [UIImage imageNamed:@"1.gif"],
                                     [UIImage imageNamed:@"2.gif"],
                                     [UIImage imageNamed:@"3.gif"],
                                     [UIImage imageNamed:@"4.gif"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

Upvotes: 2

Related Questions