如何创建具有背景和旋转图像的iPhone应用程序? [英] How do I create an iPhone app with background and rotating images?

查看:102
本文介绍了如何创建具有背景和旋转图像的iPhone应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在转向iPhone编程并找到


I am making the transition to iPhone programming and found how to display Image in ImageView? to answer some of my questions, but did not specify a couple of basics, namely what kind of project(s) can display an image, and where in the project the code can be put. I created an empty project and am getting errors for the last two lines of:

CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f);
UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; 
[myImage setImage:[UIImage imageNamed:@"myImage.png"]];
myImage.opaque = YES; // explicitly opaque for performance 
[self.view addSubview:myImage]; 
[myImage release]; 

If I am going to display a clock face, eventually one with rotating hands but for now the goal is to display the face itself, can I do it with a basic project, or do I need to start over with another project, and where should I be placing the sample code? http://www.iphoneexamples.com/ has AFAICT some excellent examples, but they seem to assume you know where to put the code in question, and that you have chosen whatever is the most appropriate project.

So, let's say I am not trying to animate the clock hands immediately, and for now I want my (PNG) clock face to show, optionally well-positioned on the screen. What kind of project do I start with, where do I put the code to display the image, and what code should I be using to display the image?

解决方案

Go to the Interface Builder or your Storyboard, if you started an empty project you probably don't have any of these, I'd recommend you to start with a Single View project, then on Interface Builder or the Storyboard, from the Library drag an Image View (also called UIImageView) and place it on your canvas, using the properties bar on the right you can set the image just like in the following image

That way you get to display an image on a view, resize the view properly to fit your image dimesions and repeat for every other image you want to add.

For what you are asking my guess is that you are pretty new to iOS Development, I can recommend you Beginning iOS 6 Development: Exploring the iOS SDK

这篇关于如何创建具有背景和旋转图像的iPhone应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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