移动iPhone应用程序背景图片 [英] Moving iPhone app background image

查看:109
本文介绍了移动iPhone应用程序背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造我的第一个iPhone本机应用程序(初学者的Objective-C)。在我的主菜单标题画面,我想的背景图像慢慢移动到左侧。是否有可能平铺的背景图像,并将它移动?基本上,我想有我的云朵横跨背景漂​​移。你将如何做到这一点?

I am creating my first iPhone native app (beginner Objective-C). On my main menu title screen, I would like the background image to move slowly to the left. Is it possible to tile a background image and have it move? I'm basically trying to have my clouds drift across the background. How would you accomplish this?

推荐答案

我想一个UIImageView添加到您的屏幕(下一切放置在屏幕上)。把云图像中的UIImageView和动画帧值,它在屏幕上移动。

I would add a UIImageView to your screen (placed under everything else on the screen). Put the clouds image in the UIImageView and animate the frame value to move it across the screen.

像这样的东西(这code是没有尝试过)将动画图像视图,向左移动在屏幕上:

Something like this (this code is untried) would animate the image view, to move left across the screen:

cloudsImage.frame = CGRectMake(0,0,320,100);   // depends on your image

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3.0f];  // duration affects how fast it moves 

cloudsImage.frame = CGRectMake(-320,0,320,100);  // moves left off the screen

[UIView commitAnimations];

您也可以设置动画相同的图像,并从右侧的第一个是走出去的左侧,使其显示为云从右边过来的连续流动的同时滑动。

You could also animate the same image and slide it in from the right at the same time the first one is going out the left side to make it appear as a continuous flow of clouds coming from the right.

cloudsImage1.frame = CGRectMake(0,0,320,100);   // depends on your image
cloudsImage2.frame = CGRectMake(320,0,320,100); // start off the right edge

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3.0f];  // duration affects how fast it moves 

cloudsImage1.frame = CGRectMake(-320,0,320,100);  // moves left off the screen
cloudsImage2.frame = CGRectMake(0,0,320,100);     // moves left onto the screen

[UIView commitAnimations];

这篇关于移动iPhone应用程序背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆