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];
精彩评论