iPhone中的动画图像层

发布于 2024-10-31 10:30:37 字数 54 浏览 0 评论 0原文

如何在 xcode 上对两组图像进行动画处理?我的意思是一组是背景或风景,另一组是背景中的人物

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 background

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惯饮孤独 2024-11-07 10:30:37

您可以尝试以下基本方法:

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

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文