{
NSTimer *scrollBackground;
}
- (void)viewDidLoad {
[super viewDidLoad];
//背景滚动动画
NSArray *imageArray = @[_image1,_image2];
//userInfo:imageArray
scrollBackground=
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self
selector:@selector(scrollBackground:) userInfo:imageArray repeats:YES];
}
- (void)scrollBackground:(NSTimer *)timer
NSArray *images = timer.userInfo;
//遍历这个数组改变背景图片的y坐标
for(UIImageView *image in images) {
//让图片下落
image.frame=CGRectMake(image.frame.origin.x, image.frame.origin.y
+1, [[UIScreenmainScreen]bounds].size.width, [[UIScreenmainScreen]bounds].size.height);
//判断是否到达临界点出屏幕后改变y坐标位置回收到屏幕上方等待下落
if(image.frame.origin.y>= [[UIScreen mainScreen]bounds].size.height) {
image.frame=CGRectMake(image.frame.origin.x,-[[UIScreen
mainScreen]bounds].size.height,[[UIScreen
mainScreen]bounds].size.width, [[UIScreen
mainScreen]bounds].size.height);
}
}