2012-11-15 177 views
0

如何循環UIImageView中的圖像?UIImageView動畫圖片

說我有三個圖像,1.jpg,2.jpg,3.jpg。如何獲取的圖片,直到用戶按什麼改變循環往復......

回答

1

這說明它非常好:[Link]

// create the view that will execute our animation 
UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame]; 

// load all the frames of our animation 
campFireView.animationImages = [NSArray arrayWithObjects:  
          [UIImage imageNamed:@"campFire01.gif"], 
          [UIImage imageNamed:@"campFire02.gif"], 
          [UIImage imageNamed:@"campFire03.gif"], 
          [UIImage imageNamed:@"campFire04.gif"], 
          [UIImage imageNamed:@"campFire05.gif"], 
          [UIImage imageNamed:@"campFire06.gif"], 
          [UIImage imageNamed:@"campFire07.gif"], 
          [UIImage imageNamed:@"campFire08.gif"], 
          [UIImage imageNamed:@"campFire09.gif"], 
          [UIImage imageNamed:@"campFire10.gif"], 
          [UIImage imageNamed:@"campFire11.gif"], 
          [UIImage imageNamed:@"campFire12.gif"], 
          [UIImage imageNamed:@"campFire13.gif"], 
          [UIImage imageNamed:@"campFire14.gif"], 
          [UIImage imageNamed:@"campFire15.gif"], 
          [UIImage imageNamed:@"campFire16.gif"], 
          [UIImage imageNamed:@"campFire17.gif"], nil]; 

// all frames will execute in 1.75 seconds 
campFireView.animationDuration = 1.75; 
// repeat the annimation forever 
campFireView.animationRepeatCount = 0; 
// start animating 
[campFireView startAnimating]; 
// add the animation view to the main window 
[self.view addSubview:campFireView]; 
+0

正是我一直在尋找,並這麼快。必須等待幾分鐘才能讓Stack接受這個答案:-) –