Tuesday, January 27, 2015

Animate images in UIImageView

-(void)addImageViewWithAnimation{ 

   UIImageView *imgview = [[UIImageView alloc]      
    initWithFrame:CGRectMake(10, 10, 300, 400)]; // set an animation 

   imgview.animationImages = [NSArray arrayWithObjects: [UIImage 
       imageNamed:@"AppleUSA1.jpg"], [UIImage   
       imageNamed:@"AppleUSA2.jpg"], nil]; 

   imgview.animationDuration = 4.0; 
   imgview.contentMode = UIViewContentModeCenter; 
   [imgview startAnimating]; 
   
   [self.view addSubview:imgview]; 

1 comment: