Hello world for iphone

首先新建一个 base windows 的 project,名字为 HelloWorldEx

然后找到 HelloWorldExAppDelegate.m 修改函数

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

的内容为

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

UILabel
*helloLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 150, 50, 50)];

[helloLabel setFont:[UIFont systemFontOfSize:
17]];
[helloLabel setLineBreakMode:UILineBreakModeWordWrap];
[helloLabel setNumberOfLines:
0];
// [helloLabel setBackgroundColor:[UIColor colorWithRed:120 green:220 blue:100 alpha:0.3]];
[helloLabel setText:@"hello World!"];
// [helloLabel setTextColor:[UIColor colorWithRed:20 green:100 blue:100 alpha:0.6]];
[self.window addSubview:helloLabel];
// [self.window setBackgroundColor:[UIColor blackColor]];
[self.window makeKeyAndVisible];
return YES;
}

  

然后再运行即可

这个例子,主要使用 UILabel 显示内容

UILabel 是一个显示静态文本的控件,它继承于 UIView

view 是显示内容的一个视图,view 可以嵌套 view 

和 view 不同的是window,一个程序只有一个window,其相当于整个屏幕,是显示内容给用户的基础

posted @ 2011-08-11 19:02  mew7wo  阅读(144)  评论(0编辑  收藏  举报