iphone中的动画图像层

时间:2011-04-11 11:05:10

标签: objective-c xcode core-animation layer

如何在xcode上另外设置两组图像?我的意思是一组是背景或风景,另一组是背景中的数字

1 个答案:

答案 0 :(得分:0)

以下是您可能尝试的基本方法:

UIImageView* backdropScene = [[UIImageView alloc] initWithFrame:self.view.frame];

backdropScene.animationImages = [NSArray arrayWithObjects:    
[UIImage imageNamed:@"rainy_background01.png"],
[UIImage imageNamed:@"rainy_background02.png"],
[UIImage imageNamed:@"rainy_background03.png"],
[UIImage imageNamed:@"rainy_background04.png"], nil];

backdropScene.animationDuration = .2f; // image change rate, .2 seconds
backdropScene.animationRepeatCount = 0; // repeat infinitely
[self.view addSubview:backdropScene];
[backdropScene startAnimation];


UIImageView* foregroundAnimation = [[UIImageView alloc] initWithFrame:self.view.frame];

foregroundAnimation.animationImages = [NSArray arrayWithObjects:    
[UIImage imageNamed:@"man_walk01.png"],
[UIImage imageNamed:@"man_walk02.png"],
[UIImage imageNamed:@"man_walk03.png"],
[UIImage imageNamed:@"man_walk04.png"], nil];

foregroundAnimation.animationDuration = .5f; // image change rate, .2 seconds
foregroundAnimation.animationRepeatCount = 0; // repeat infinitely
[self.view addSubview:foregroundAnimation];
[foregroundAnimation startAnimation];