2011-11-03 190 views
-3

我需要在UIView與UIImageView實現幻燈片放映。有沒有任何代碼在運行時使用定時器加載圖像視圖?如果任何人可以請提供代碼,這將是有益的。 預先感謝.....在UIView幻燈片放映

+0

嘗試做不透明動畫 – banu

回答

0

動畫使用的代碼的視圖...

的UIImageView * campFireView = [[ALLOC的UIImageView] initWithFrame:方法self.view.frame];

// load all the frames of our animation 
campFireView.animationImages = [NSArray arrayWithObjects:  
           [UIImage imageNamed:@"welcome-1.tiff"], 
           [UIImage imageNamed:@"welcome-2.tiff"], 
           [UIImage imageNamed:@"welcome-3.tiff"], 
           nil]; 

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

NSArray *imageArray = [NSArray arrayWithObjects: [UIImage imageNamed:@"nature1.png"], [UIImage imageNamed:@"nature2.png"], [UIImage imageNamed:@"nature3.png"], [UIImage imageNamed:@"nature4.png"],[UIImage imageNamed:@"nature5.png"],[UIImage imageNamed:@"nature6.png"] nil]; 
UIImageView *slidShowImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)]; 
slidShowImageView.animationImages = imageArray; 
slidShowImageView.animationDuration = 0.25; 
slidShowImageView.animationRepeatCount = 0; 
[slidShowImageView startAnimating]; 
[self addSubview:slidShowImageView]; 
[slidShowImageView release];