开发者

layer of animation images in iphone

开发者 https://www.devze.com 2023-02-23 07:06 出处:网络
How I can animate two sets of images one on the other on xcode? I mean that one set is background or landscape and the other set is a figure in the bac开发者_Python百科kgroundHere\'s a basic approach

How I can animate two sets of images one on the other on xcode? I mean that one set is background or landscape and the other set is a figure in the bac开发者_Python百科kground


Here's a basic approach you might try:

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消