2011-11-03 144 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];