2009-04-29 54 views

回答

9

在大多数情况下,你使用的ViewController。但是可以直接在窗口中添加UIView。也许你可以更多地解释你想要做什么。

UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)]; 
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; 
[label setFont:[UIFont boldSystemFontOfSize:18]]; 
[label setTextAlignment:UITextAlignmentCenter]; 
[label setBackgroundColor:[UIColor clearColor]]; 
[label setTextColor:[UIColor whiteColor]]; 
[label setText:@"Hello"]; 
[view addSubview:label]; 
[window addSubview:view]; 

你可以得到一个referens到窗口(如果你不已经有一个)与

[[UIApplication sharedApplication] keyWindow]; 
+0

PLZ告诉我在哪里,我写的代码。我需要添加一个新的uiview子类吗? – 2009-04-29 08:41:02

相关问题